1 |
HTTP Working Group Koen Holtman, TUE |
2 |
Internet-Draft Andrew Mutz, Hewlett-Packard |
3 |
Expires: May 15, 1998 Ted Hardie, NASA NIC |
4 |
|
5 |
|
6 |
|
7 |
The Alternates Header Field |
8 |
|
9 |
draft-ietf-http-alternates-01.txt |
10 |
|
11 |
|
12 |
STATUS OF THIS MEMO |
13 |
|
14 |
This document is an Internet-Draft. Internet-Drafts are |
15 |
working documents of the Internet Engineering Task Force |
16 |
(IETF), its areas, and its working groups. Note that other |
17 |
groups may also distribute working documents as |
18 |
Internet-Drafts. |
19 |
|
20 |
Internet-Drafts are draft documents valid for a maximum of |
21 |
six months and may be updated, replaced, or obsoleted by |
22 |
other documents at any time. It is inappropriate to use |
23 |
Internet-Drafts as reference material or to cite them other |
24 |
than as "work in progress". |
25 |
|
26 |
To learn the current status of any Internet-Draft, please |
27 |
check the "1id-abstracts.txt" listing contained in the |
28 |
Internet-Drafts Shadow Directories on ftp.is.co.za |
29 |
(Africa), nic.nordu.net (Europe), munnari.oz.au (Pacific |
30 |
Rim), ds.internic.net (US East Coast), or ftp.isi.edu (US |
31 |
West Coast). |
32 |
|
33 |
Distribution of this document is unlimited. Though this |
34 |
work originated in the HTTP working group and comments |
35 |
should continue to be directed to that group, the authors |
36 |
expect that the proposed header will have considerable use |
37 |
outside of HTTP. Discussions about its potential uses |
38 |
outside of HTTP are particularly sought by the authors. |
39 |
Send comments to the HTTP working group at |
40 |
<http-wg@cuckoo.hpl.hp.com>. Discussions of the working |
41 |
group are archived at |
42 |
<URL:http://www.ics.uci.edu/pub/ietf/http/>. General |
43 |
discussions about HTTP and the applications which use HTTP |
44 |
should take place on the <www-talk@w3.org> mailing list. |
45 |
|
46 |
|
47 |
ABSTRACT |
48 |
|
49 |
This document proposes a header, Alternates, which is intended |
50 |
to provide a common method for Internet-based application |
51 |
protocols to indicate that a particular resource exists in |
52 |
multiple forms. The Alternates header provides a |
53 |
machine-readable indication of the bases on which the |
54 |
different forms vary and how the the recipient of the header |
55 |
can select among them. |
56 |
|
57 |
|
58 |
1 Introduction |
59 |
|
60 |
Where a particular content provider has created more than |
61 |
one representation of a specific resource, the provider may |
62 |
wish to indicate the existance of the different representations, |
63 |
or "variants", to those who might want to select among them. |
64 |
Rather than consuming bandwidth by sending all available variants, |
65 |
the content provider can employ the Alternates header to |
66 |
indicate what variants are available, the bases on which |
67 |
the variants differ, and how to select a specific variant. |
68 |
|
69 |
The functionality of the Alternates header is similar to |
70 |
that of the Multipart/Alternative MIME type[Ref] where the |
71 |
Multipart/Alternative object has all external message bodies. |
72 |
The Alternates header differs in that it does not rank |
73 |
the alternatives. Instead, it provides information which |
74 |
allows the recipient to decide among them based on the |
75 |
provider's estimation of their quality, local capabilities, |
76 |
and preferences. |
77 |
|
78 |
2 Terminology |
79 |
|
80 |
The words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", and |
81 |
"MAY" in this document are to be interpreted as described in |
82 |
RFC 2119 [Ref]. |
83 |
|
84 |
|
85 |
3 Notation |
86 |
|
87 |
The version of BNF used in this document is taken from [Ref], and |
88 |
many of the nonterminals used are defined in [Ref]. |
89 |
|
90 |
|
91 |
4.1 Definition |
92 |
|
93 |
The Alternates header field describes all available |
94 |
variants for a specific resource. The description for each |
95 |
variant includes an URI from which this |
96 |
variant can be retrieved. |
97 |
|
98 |
Alternates = "Alternates" ":" variant-list |
99 |
|
100 |
variant-list = 1#( variant-description ; see section 5 |
101 |
| fallback-variant |
102 |
| negotiation-directive ) |
103 |
|
104 |
fallback-variant = "{" <"> URI <"> "}" |
105 |
|
106 |
negotiation-directive = token [ "=" ( token | quoted-string ) ] |
107 |
|
108 |
An example is |
109 |
|
110 |
Alternates: {"http://x.org/paper.1" 0.9 {type text/html} {language en}}, |
111 |
{"http://x.org/paper.2" 0.7 {type text/html} {language fr}}, |
112 |
{"ftp://x.org/pub/paper.3" 1.0 {type application/postscript} |
113 |
{language en}}, |
114 |
{"http://x.org/paper.html.en"}, x=y |
115 |
|
116 |
A variant list may contain multiple differing descriptions of the |
117 |
same variant. This can be convenient if the variant uses |
118 |
conditional rendering constructs, or if the variant resource |
119 |
returns multiple representations using a multipart media type. |
120 |
|
121 |
Only one fallback-variant field may be present. If the variant |
122 |
selection algorithm of the user agent finds that all variants |
123 |
described by variant-description fields are unacceptable, then it |
124 |
SHOULD choose the fallback variant, if present, as the best |
125 |
variant. |
126 |
|
127 |
This specification does not define any specific negotiation |
128 |
directives for the Alternates header field. User agents SHOULD |
129 |
ignore all negotiation directives they do not understand. If a |
130 |
proxy receives an Alternates header field with an unknown |
131 |
negotiation directive, it SHOULD, whenever possible, forward the |
132 |
response towards the user agent instead of trying to take part in a |
133 |
negotiation process itself. |
134 |
|
135 |
|
136 |
4.2 Length of variant lists |
137 |
|
138 |
As a general rule, variant lists in Alternates header fields should |
139 |
be as short as possible. The use of multiple differing descriptions |
140 |
of the same variant is supported, but should be limited to those |
141 |
resources which cannot easily be expressed without the use of |
142 |
condititional constructs or multipart media types. It is expected |
143 |
that a typical negotiable resource will have 2 to 10 variants. |
144 |
In situations where many more variants are available, more sophisticated |
145 |
methods than the Alternates header field should be used. |
146 |
|
147 |
|
148 |
5 Variant descriptions |
149 |
|
150 |
5.1 Syntax |
151 |
|
152 |
A variant can be described in a machine-readable way with a variant |
153 |
description. |
154 |
|
155 |
variant-description = |
156 |
"{" <"> URI <"> source-quality *variant-attribute"}" |
157 |
|
158 |
source-quality = qvalue |
159 |
|
160 |
variant-attribute = "{" "type" media-type "}" |
161 |
| "{" "charset" charset "}" |
162 |
| "{" "language" 1#language-tag "}" |
163 |
| "{" "length" 1*DIGIT "}" |
164 |
| extension-attribute |
165 |
|
166 |
extension-attribute = "{" extension-name extension-value "}" |
167 |
extension-name = token |
168 |
extension-value = *( token | quoted-string | LWS |
169 |
| extension-specials ) |
170 |
|
171 |
extension-specials = |
172 |
<any element of tspecials except <"> and "}"> |
173 |
|
174 |
Examples are |
175 |
|
176 |
{"http://x.org/paper.2" 0.7 {type text/html} {language fr}} |
177 |
|
178 |
{"http://x.org/paper.5" 0.9 {type text/html} {length 1002}} |
179 |
|
180 |
{"http://x.org/paper.1" 0.001} |
181 |
|
182 |
The various attributes which can be present in a variant |
183 |
description are covered in the subsections below. Each attribute |
184 |
may appear only once in a variant description. |
185 |
|
186 |
|
187 |
5.2 URI |
188 |
|
189 |
The URI attribute gives the URI of the resource from which the |
190 |
variant can be retrieved with a GET request. It must be an |
191 |
absolute URI, in order to allow for this header to be passed |
192 |
to other MIME transport protocols without transformation. |
193 |
The variant resource may vary the content it sends (on the Cookie |
194 |
request header field, for example), but SHOULD NOT engage |
195 |
in content negotiation itself. |
196 |
|
197 |
|
198 |
5.3 Source-quality |
199 |
|
200 |
The source-quality attribute gives the quality of the variant, as a |
201 |
representation of the negotiable resource, when this variant is |
202 |
rendered with a perfect rendering engine on the best possible |
203 |
output medium. |
204 |
|
205 |
If the source-quality is less than 1, it often expresses a quality |
206 |
degradation caused by a lossy conversion to a particular data |
207 |
format. For example, a picture originally in JPEG form would have |
208 |
a lower source quality when translated to the XBM format, and a |
209 |
much lower source quality when translated to an ASCII-art variant. |
210 |
Note however, that degradation is a function of the source; an |
211 |
original piece of ASCII-art may degrade in quality if it is |
212 |
captured in JPEG form. |
213 |
|
214 |
Servers should use the following table a guide when assigning |
215 |
source quality values: |
216 |
|
217 |
1.000 perfect representation |
218 |
0.900 threshold of noticeable loss of quality |
219 |
0.800 noticeable, but acceptable quality reduction |
220 |
0.500 barely acceptable quality |
221 |
0.300 severely degraded quality |
222 |
0.000 completely degraded quality |
223 |
|
224 |
In the source-quality values, servers should not account for the |
225 |
size of the variant and its impact on transmission and rendering |
226 |
delays; the size of the variant should be stated in the length |
227 |
attribute and any size-dependent calculations should be done by a |
228 |
variant selection algorithm in the user agent. |
229 |
|
230 |
|
231 |
5.4 Type, charset, language, and length |
232 |
|
233 |
The type attribute of a variant description carries the same |
234 |
information as its Content-Type response header field counterpart |
235 |
defined in [1], except for any charset information, which MUST be |
236 |
carried in the charset attribute. For, example, the header field |
237 |
|
238 |
Content-Type: text/html; charset=ISO-8859-4 |
239 |
|
240 |
has the counterpart attributes |
241 |
|
242 |
{type text/html} {charset ISO-8859-4} |
243 |
|
244 |
The language and length attributes carry the same information as |
245 |
their Content-* response header field counterparts in [1]. The |
246 |
length attribute, if present, MUST thus reflect the length of the |
247 |
variant alone, and not the total size of the variant and any |
248 |
objects inlined or embedded by the variant. |
249 |
|
250 |
Though all of these attributes are optional, it is often desirable |
251 |
to include as many attributes as possible, as this will increase |
252 |
the quality of the negotiation process. |
253 |
|
254 |
Note: A server is not required to maintain a one-to-one |
255 |
correspondence between the attributes in the variant description |
256 |
and the Content-* header fields in the variant response. For |
257 |
example, if the variant description contains a language |
258 |
attribute, the response does not necessarily have to contain a |
259 |
Content-Language header field. If a Content-Language header |
260 |
field is present, it does not have to contain an exact copy of |
261 |
the information in the language attribute. |
262 |
|
263 |
|
264 |
5.5 Extension-attribute |
265 |
|
266 |
The extension-attribute allows future specifications to |
267 |
incrementally define new dimensions of negotiation, and eases |
268 |
content negotiation experiments. User agents conforming to this |
269 |
specification SHOULD treat all variants with extension attributes |
270 |
they do not recognize as unusable. Proxies SHOULD NOT do any |
271 |
negotiation processing for a response if an extension attribute |
272 |
unknown to them is present in the variant list. They SHOULD |
273 |
forward the response unchanged towards the user agent instead. |
274 |
|
275 |
The extension names "features" and "description" are reserved by |
276 |
this specification for use in transparent content negotiation [4]. |
277 |
|
278 |
|
279 |
6 Use of the Alternates header field |
280 |
|
281 |
This section defines conventions and guidelines for the use of the |
282 |
Alternates header field. |
283 |
|
284 |
|
285 |
6.1 Use accompanying a variant |
286 |
|
287 |
A resource provider may provide a recipient with a particular |
288 |
variant together with an Alternates header field which notifies |
289 |
the recipient that multiple variants are available. An HTTP |
290 |
example of such an exchange is: |
291 |
|
292 |
HTTP/1.1 200 OK |
293 |
Date: Tue, 11 Jun 1996 20:05:31 GMT |
294 |
Content-Type: text/html |
295 |
Content-Language: en |
296 |
Last-Modified: Mon, 10 Jun 1996 10:01:14 GMT |
297 |
Content-Length: 5327 |
298 |
Alternates: {"http://x.org/paper.1" 0.9 {type text/html} {language en}}, |
299 |
{"http://x.org/paper.2" 0.7 {type text/html} {language fr}}, |
300 |
{"http://x.org/paper.3" 1.0 {type application/postscript} |
301 |
{language en}} |
302 |
Content-Location: http://x.org/paper.1 |
303 |
Vary: * |
304 |
Expires: Thu, 01 Jan 1980 00:00:00 GMT |
305 |
Cache-Control: max-age=604800 |
306 |
|
307 |
<title>A paper about .... |
308 |
|
309 |
In this response, the Content-Location header field tells the user |
310 |
agent which variant was included. The Vary, Expires, and |
311 |
Cache-Control header fields ensure proper handling of the response |
312 |
by HTTP/1.0 and HTTP/1.1 caches. |
313 |
|
314 |
When detecting that an Alternates header field is present, a user |
315 |
agent MAY choose to use a variant selection algorithm to select the |
316 |
best variant of the negotiable resource. If the best variant is |
317 |
not the same one as the one identified by the Content-Location |
318 |
header field, the user agent MAY use the URI indicated for the |
319 |
best version to obtain it. |
320 |
|
321 |
|
322 |
6.2 Use when a variant is not present |
323 |
|
324 |
A content provider may also inform a potential recipient that |
325 |
multiple variants exist without providing any particular variant. |
326 |
In such exchanges, the content provider should omit the |
327 |
Content-Location header. A message body MAY accompany the |
328 |
headers used to convey this information. An SMTP example |
329 |
of such an exchange is: |
330 |
|
331 |
|
332 |
220 ESMTP spoken here |
333 |
EHLO mail.x.org |
334 |
250-mail.y.org Hello mail.x.org, pleased to meet you |
335 |
MAIL FROM: lists@mail.x.org |
336 |
250 lists@mail.x.org... Sender ok |
337 |
RCPT TO: exploder-lists@mail.y.org |
338 |
250 exploder-lists@mail.y.org... Recipient ok |
339 |
DATA |
340 |
354 Enter mail, end with "."on a line by itself |
341 |
To: exploder-lists@mail.y.org |
342 |
From: lists@mail.x.org |
343 |
Date: Tue, 11 Jun 1996 20:02:21 GMT |
344 |
Content-Type: text/htm |
345 |
Content-Length: 227 |
346 |
Alternates: {"http://x.org/paper.1" 0.9 {type text/html} {language en}}, |
347 |
{"http://x.org/paper.2" 0.7 {type text/html} {language fr}}, |
348 |
{"http://x.org/paper.3" 1.0 {type application/postscript} |
349 |
{language en}} |
350 |
Vary: * |
351 |
|
352 |
<h1>Multiple Choices:</h1> |
353 |
<ul> |
354 |
<li><a href=paper.1>HTML, English version</a> |
355 |
<li><a href=paper.2>HTML, French version</a> |
356 |
<li><a href=paper.3>Postscript, English version</a> |
357 |
</ul> |
358 |
. |
359 |
250 XAA13385 Message accepted for delivery |
360 |
|
361 |
|
362 |
On receipt of such a message, the user agent MAY use a variant |
363 |
selection algorithm to select the best variant of the negotiable |
364 |
resource, and retrieve this variant. For compatibility with user |
365 |
agents which are not capable of handling the Alternates header |
366 |
field, any message body should normally allow the user to select |
367 |
the best variant manually. |
368 |
|
369 |
|
370 |
6.3 Use of redirection to optimize availability |
371 |
|
372 |
HTTP and related protocols allow an origin server to indicate |
373 |
that a resource is available but is not at the URL by which it |
374 |
was requested. As an optimization, the Alternates header can |
375 |
be used in combination with this redirection to allow an origin |
376 |
server to indicate the availability of variant resources without |
377 |
including a resource or excluding user agents which do not support |
378 |
the Alternates header. By providing the fallback variant's URL |
379 |
in the location header, the origin server can ensure that all user |
380 |
agents will have access to that variant, while the full list of |
381 |
variants is provided in the Alternates header for more capable |
382 |
user agents. |
383 |
|
384 |
An example of this usage in an HTTP response is: |
385 |
|
386 |
HTTP/1.1 302 Moved Temporarily |
387 |
Date: Tue, 11 Jun 1996 20:05:31 GMT |
388 |
Content-Type: text/html |
389 |
Alternates: {"http://x.org/paper.1" 0.9 {type text/html} {language en}}, |
390 |
{"http://x.org/paper.2" 0.7 {type text/html} {language fr}}, |
391 |
{"http://x.org/paper.3" 1.0 {type application/postscript} |
392 |
{language en}} |
393 |
Location: http://x.org/paper.1 |
394 |
Content-Length: 67 |
395 |
|
396 |
This document is available <a href="http://x.org/paper.1">here</a>. |
397 |
|
398 |
Note the use of a Location header field instead of a |
399 |
Content-Location header field. On receipt of such a response, |
400 |
user agents which understand the Alternates header SHOULD use |
401 |
a variant selection algorithm to select the best variant of the |
402 |
negotiable resource, and retrieve this variant. When the Alternates |
403 |
header is used in protocols which do not provide redirection, the |
404 |
method outlined in section 6.1 should be used when the content |
405 |
provider wishes to ensure at least one variant is made available |
406 |
to all recipients. |
407 |
|
408 |
|
409 |
6.4 User agent guidelines |
410 |
|
411 |
Summarizing the three sections above, if an Alternates header field |
412 |
is present in the response, then |
413 |
|
414 |
* a recipient SHOULD use its variant selection algorithm to |
415 |
choose and retrieve the best variant if a Content-Location |
416 |
header field is absent, |
417 |
|
418 |
* and MAY use its variant selection algorithm to choose and |
419 |
retrieve the best variant if a Content-Location header field |
420 |
is present. |
421 |
|
422 |
6.4.1 Interactive user agent guidelines |
423 |
|
424 |
For user agents which provide direct interaction with users, the |
425 |
following guidelines apply: |
426 |
|
427 |
1. The user agent SHOULD make available though its user interface |
428 |
some indication that the resource being displayed is a |
429 |
negotiated resource instead of a plain resource. It SHOULD |
430 |
also allow the user to examine the variant list included in the |
431 |
Alternates header field. Such a notification and review |
432 |
mechanism is needed because of privacy considerations, see |
433 |
section 7.1. |
434 |
|
435 |
2. If the user agent shows the URI of the displayed information to |
436 |
the user, it SHOULD be the negotiable resource URI, not the |
437 |
variant URI that is shown. This encourages third parties, who |
438 |
want to refer to the displayed information in their own |
439 |
documents, to refer to the negotiable resource as a whole, |
440 |
rather than to the variant resource which happens to be |
441 |
shown. This abstract referencing is vital for the interoperability |
442 |
of content across sites. The user agent SHOULD also, however, |
443 |
provide a means for reviewing the URI of the particular variant |
444 |
which is currently being displayed. |
445 |
|
446 |
3. Similarly, if the user agent stores a reference to the |
447 |
displayed information for future use, for example in a hotlist, |
448 |
it SHOULD store the negotiable resource URI, not the variant |
449 |
URI. |
450 |
|
451 |
6.4.2 Non-interactive user agent guidelines |
452 |
|
453 |
Devices like printers, fax machines, or text processors may also be |
454 |
the recipients of the Alternates header. Since such devices |
455 |
typically function without direct interaction with a human operator, |
456 |
the user agent guidelines given above do not directly apply. |
457 |
Many of the same principals, however, can be employed. For |
458 |
example, a device which generates a log report or cover sheet |
459 |
which contains information about the information received could |
460 |
provide the same information described above in that form. |
461 |
|
462 |
6.5 Negotiation on content encoding |
463 |
|
464 |
Negotiation on the content encoding of a response is orthogonal to |
465 |
content negotiation based on the Alternates header field. |
466 |
|
467 |
|
468 |
6.6 Role of proxies |
469 |
|
470 |
This specification does not define mechanisms by which proxies can |
471 |
use the Alternates header field, but does allow other |
472 |
specifications to define such mechanisms. To ensure extensibility |
473 |
of the Alternates header field, this specification does however |
474 |
define, in section 4.1 and section 5.5, that a proxy should not |
475 |
engage in a negotiation process when encountering an Alternates |
476 |
header field which has a component unknown to it. |
477 |
|
478 |
|
479 |
7 Security and privacy considerations |
480 |
|
481 |
7.1 Variants hiding the source of displayed material. |
482 |
|
483 |
The Variants header may be used to allow a |
484 |
user to select among variants available from more than |
485 |
one location. In such cases, users may make incorrect |
486 |
asssumptions about the origin of particular resources. |
487 |
The guidlines given in 6.4 alleviate this problem to |
488 |
a degree, but some implementors of the Alternates header |
489 |
may wish to provide further warnings or filters. |
490 |
|
491 |
7.2 User agent choices revealing information of a private nature |
492 |
|
493 |
The automatic selection and retrieval of a variant by a user agent |
494 |
will reveal a preference for this variant to the server. A |
495 |
malicious service author could provide a page with `fake' |
496 |
negotiability as a means of obtaining privacy-sensitive information. |
497 |
Such a plot would, however, be visible to an alert victim if the list |
498 |
of available variants and their properties is reviewed through a |
499 |
mechanism as described in section 6.4.1. |
500 |
|
501 |
7.3 Security holes revealed by negotiation |
502 |
|
503 |
Malicious servers could use content negotiation as a means of |
504 |
obtaining information about security holes which may be present in |
505 |
user agents. |
506 |
|
507 |
|
508 |
8 Acknowledgments |
509 |
|
510 |
Work on HTTP content negotiation has been done since at least 1993. |
511 |
This specification builds on an earlier incomplete specification of |
512 |
the Alternates header field recorded in [2]. The authors wish to |
513 |
thank the individuals who have contributed to the work on content |
514 |
negotiation in the HTTP working group, including Brian Behlendorf, |
515 |
Daniel DuBois, Martin J. Duerst, Roy T. Fielding, Jim Gettys, Yaron |
516 |
Goland, Dirk van Gulik, Graham Klyne, Scott Lawrence, |
517 |
Larry Masinter, Jeffrey Mogul, Henrik Frystyk Nielsen, Frederick |
518 |
G.M. Roeber, Paul Sutton, and Klaus Weide. |
519 |
|
520 |
|
521 |
9 References |
522 |
|
523 |
[1] R. Fielding, J. Gettys, J. C. Mogul, H. Frystyk, and |
524 |
T. Berners-Lee. Hypertext Transfer Protocol -- HTTP/1.1. RFC |
525 |
2068, HTTP Working Group, January 1997. |
526 |
|
527 |
[2] Roy T. Fielding, Henrik Frystyk Nielsen, and Tim Berners-Lee. |
528 |
Hypertext Transfer Protocol -- HTTP/1.1. Internet-Draft |
529 |
draft-ietf-http-v11-spec-01.txt, HTTP Working Group, January |
530 |
1996. |
531 |
|
532 |
[3] T. Berners-Lee, R. Fielding, and H. Frystyk. Hypertext |
533 |
Transfer Protocol -- HTTP/1.0. RFC 1945. MIT/LCS, UC Irvine, |
534 |
May 1996. |
535 |
|
536 |
[4] K. Holtman, A. Mutz. Transparent Content Negotiation in HTTP. |
537 |
Internet-Draft draft-ietf-http-negotiation-04.txt, HTTP Working |
538 |
Group, September 1997. |
539 |
|
540 |
[5] S. Bradner. Key words for use in RFCs to Indicate Requirement |
541 |
Levels. RFC 2119. Harvard University, March 1997. |
542 |
|
543 |
|
544 |
10 Authors' addresses |
545 |
|
546 |
Koen Holtman |
547 |
Technische Universiteit Eindhoven |
548 |
Postbus 513 |
549 |
Kamer HG 6.57 |
550 |
5600 MB Eindhoven (The Netherlands) |
551 |
Email: koen@win.tue.nl |
552 |
|
553 |
Andrew H. Mutz |
554 |
Hewlett-Packard Company |
555 |
1501 Page Mill Road 3U-3 |
556 |
Palo Alto CA 94304, USA |
557 |
Fax +1 415 857 4691 |
558 |
Email: mutz@hpl.hp.com |
559 |
|
560 |
|
561 |
Ted Hardie |
562 |
NASA NIC |
563 |
Mail Stop 204-14 |
564 |
NASA Ames Research Center |
565 |
Moffett Field, CA 94035 |
566 |
Email: hardie@nic.nasa.gov |
567 |
|
568 |
11 Appendix: Example of a variant selection algorithm |
569 |
|
570 |
A negotiating user agent will choose the best variant from a |
571 |
variant list with a variant selection algorithm. This appendix |
572 |
contains an example of such an algorithm. |
573 |
|
574 |
The inputs of the algorithm are a variant list from an Alternates |
575 |
header field, and an agent-side configuration database, which |
576 |
contains |
577 |
|
578 |
- a collection of quality values assigned to media types, |
579 |
languages, and charsets for the current request, following the |
580 |
model of the corresponding HTTP/1.1 [1] Accept- header fields, |
581 |
|
582 |
- a table which lists `forbidden' combinations of media types and |
583 |
charsets, i.e. combinations which cannot be displayed because |
584 |
of some internal user agent limitation. |
585 |
|
586 |
The output of the algorithm is either the best variant, or the |
587 |
conclusion that none of the variants are acceptable. |
588 |
|
589 |
|
590 |
11.1 Computing overall quality values |
591 |
|
592 |
As a first step in the variant selection algorithm, the |
593 |
overall qualities associated with all variant descriptions in the |
594 |
list are computed. |
595 |
|
596 |
The overall quality Q of a variant description is the value |
597 |
|
598 |
Q = round5( qs * qt * qc * ql * qa ) |
599 |
|
600 |
where rounds5 is a function which rounds a floating point value to |
601 |
5 decimal places after the point. It is assumed that the user |
602 |
agent can run on multiple platforms: the rounding function makes |
603 |
the algorithm independent of the exact characteristics of the |
604 |
underlying floating point hardware. |
605 |
|
606 |
The factors qs, qt, qc, ql, and qa are determined as follows. |
607 |
|
608 |
qs Is the source quality factor in the variant description. |
609 |
|
610 |
qt The media type quality factor is 1 if there is no type |
611 |
attribute in the variant description. Otherwise, it is the |
612 |
quality value assigned to this type by the configuration |
613 |
database. If the database does not assign a value, then the |
614 |
factor is 0. |
615 |
|
616 |
qc The charset quality factor is 1 if there is no charset |
617 |
attribute in the variant description. Otherwise, it is the |
618 |
quality value assigned to this charset by the configuration |
619 |
database. If the database does not assign a value, then the |
620 |
factor is 0. |
621 |
|
622 |
ql The language quality factor is 1 if there is no language |
623 |
attribute in the variant description. Otherwise, it is the |
624 |
highest quality value the configuration database assigns to |
625 |
any of the languages listed in the language attribute. If |
626 |
the database does not assign a value to any of the languages |
627 |
listed, then the factor is 0. |
628 |
|
629 |
qa The quality adjustment factor is 0 if the variant description |
630 |
lists a media type - charset combination which is `forbidden' |
631 |
by the table, and 1 otherwise. |
632 |
|
633 |
As an example, if a variant list contains the variant description |
634 |
|
635 |
{"paper.2" 0.7 {type text/html} {language fr}} |
636 |
|
637 |
and if the configuration database contains the quality value |
638 |
assignments |
639 |
|
640 |
types: text/html;q=1.0, type application/postscript;q=0.8 |
641 |
languages: en;q=1.0, fr;q=0.5 |
642 |
|
643 |
then the variant selection algorithm will compute the overall |
644 |
quality for the variant description as follows: |
645 |
|
646 |
{"paper.2" 0.7 {type text/html} {language fr}} |
647 |
| | | |
648 |
| | | |
649 |
V V V |
650 |
round5 ( 0.7 * 1.0 * 0.5 ) = 0.35000 |
651 |
|
652 |
With same configuration database, the variant list |
653 |
|
654 |
{"paper.1" 0.9 {type text/html} {language en}}, |
655 |
{"paper.2" 0.7 {type text/html} {language fr}}, |
656 |
{"paper.3" 1.0 {type application/postscript} {language en}} |
657 |
|
658 |
would yield the following computations: |
659 |
|
660 |
round5 ( qs * qt * qc * ql * qa ) = Q |
661 |
--- --- --- --- --- |
662 |
paper.1: 0.9 * 1.0 * 1.0 * 1.0 * 1.0 = 0.90000 |
663 |
paper.1: 0.7 * 1.0 * 1.0 * 0.5 * 1.0 = 0.35000 |
664 |
paper.3: 1.0 * 0.8 * 1.0 * 1.0 * 1.0 = 0.80000 |
665 |
|
666 |
|
667 |
11.2 Determining the result |
668 |
|
669 |
Using all computed overall quality values, the end result of the |
670 |
variant selection algorithm is determined as follows. |
671 |
|
672 |
If all overall quality values are 0, then the best variant is the |
673 |
fallback variant, if there is one in the Alternates header field, |
674 |
else the result is the conclusion that none of the variants are |
675 |
acceptable. |
676 |
|
677 |
If at least one overall quality value is greater than 0, then the |
678 |
best variant is the variant which has the description with the |
679 |
highest overall quality value, or, if there are multiple variant |
680 |
descriptions which share the highest overall quality value, the |
681 |
variant of the first variant description in the list which has this |
682 |
highest overall quality value. |
683 |
|
684 |
|
685 |
11.3 Ranking dimensions |
686 |
|
687 |
Consider the following variant list: |
688 |
|
689 |
{"paper.greek" 1.0 {language el} {charset ISO-8859-7}}, |
690 |
{"paper.english" 1.0 {language en} {charset ISO-8859-1}} |
691 |
|
692 |
It could be the case that the user prefers the language "el" over |
693 |
"en", while the user agent can render "ISO-8859-1" better than |
694 |
"ISO-8859-7". The result is that in the language dimension, the |
695 |
first variant is best, while the second variant is best in the |
696 |
charset dimension. In this situation, it would be preferable to |
697 |
choose the first variant as the best variant: the user settings in |
698 |
the language dimension should take precedence over the hard-coded |
699 |
values in the charset dimension. |
700 |
|
701 |
To express this ranking between dimensions, the user agent |
702 |
configuration database should have a higher spread in the quality |
703 |
values for the language dimension than for the charset dimension. |
704 |
For example, with |
705 |
|
706 |
languages: el;q=1.0, en-gb;q=0.7, en;q=0.6, da;q=0, ... |
707 |
|
708 |
charsets: ISO-8859-1;q=1.0, ISO-8859-7;q=0.95, |
709 |
ISO-8859-5;q=0.97, unicode-1-1;q=0, ... |
710 |
|
711 |
the first variant will have an overall quality of 0.95000, while |
712 |
the second variant will have an overall quality 0.70000. This |
713 |
makes the first variant the best variant. |
714 |
|
715 |
|
716 |
Expires: May 15, 1998 |
717 |
|