rfc2296.txt
字号:
Network Working Group K. HoltmanRequest for Comments: 2296 TUECategory: Experimental A. Mutz Hewlett-Packard March 1998 HTTP Remote Variant Selection Algorithm -- RVSA/1.0Status of this Memo This memo defines an Experimental Protocol for the Internet community. It does not specify an Internet standard of any kind. Discussion and suggestions for improvement are requested. Distribution of this memo is unlimited.Copyright Notice Copyright (C) The Internet Society (1998). All Rights Reserved.ABSTRACT HTTP allows web site authors to put multiple versions of the same information under a single URL. Transparent content negotiation is a mechanism for automatically selecting the best version when the URL is accessed. A remote variant selection algorithm can be used to speed up the transparent negotiation process. This document defines the remote variant selection algorithm with the version number 1.0.TABLE OF CONTENTS 1 Introduction...............................................2 2 Terminology and notation...................................2 3 The remote variant selection algorithm.....................2 3.1 Input....................................................2 3.2 Output...................................................3 3.3 Computing overall quality values.........................3 3.4 Definite and speculative quality values..................5 3.5 Determining the result...................................6 4 Use of the algorithm.......................................7 4.1 Using quality factors to rank preferences................7 4.2 Construction of short requests...........................8 4.2.1 Collapsing Accept- header elements.....................8 4.2.2 Omitting Accept- headers...............................9 4.2.3 Dynamically lengthening requests.......................9 4.3 Differences between the local and the remote algorithm..10 4.3.1 Avoiding major differences............................11 4.3.2 Working around minor differences......................11Holtman & Mutz Experimental [Page 1]RFC 2296 HTTP RVSA/1.0 March 1998 5 Security and privacy considerations.......................11 6 Acknowledgments...........................................12 7 References................................................12 8 Authors' Addresses........................................12 9 Full Copyright Statement..................................131 Introduction HTTP allows web site authors to put multiple versions (variants) of the same information under a single URL. Transparent content negotiation [2] is a mechanism for automatically selecting the best variant when the URL is accessed. A remote variant selection algorithm can be used by a HTTP server to choose a best variant on behalf of a negotiating user agent. The use of a remote algorithm can speed up the transparent negotiation process by eliminating a request-response round trip. This document defines the remote variant selection algorithm with the version number 1.0. The algorithm computes whether the Accept- headers in the request contain sufficient information to allow a choice, and if so, which variant must be chosen.2 Terminology and notation This specification uses the terminology and notation of the HTTP transparent content negotiation specification [2].3 The remote variant selection algorithm This section defines the remote variant selection algorithm with the version number 1.0. To implement this definition, a server MAY run any algorithm which gives equal results. Note: According to [2], servers are always free to return a list response instead of running a remote algorithm. Therefore, whenever a server may run a remote algorithm, it may also run a partial implementation of the algorithm, provided that the partial implementation always returns List_response when it cannot compute the real result.3.1 Input The algorithm is always run for a particular request on a particular transparently negotiable resource. It takes the following information as input. 1. The variant list of the resource, as present in the Alternates header of the resource.Holtman & Mutz Experimental [Page 2]RFC 2296 HTTP RVSA/1.0 March 1998 2. (Partial) Information about capabilities and preferences of the user agent for this particular request, as given in the Accept- headers of the request. If a fallback variant description {"fallback.html"} is present in the Alternates header, the algorithm MUST interpret it as the variant description {"fallback.html" 0.000001} The extremely low source quality value ensures that the fallback variant only gets chosen if all other options are exhausted.3.2 Output As its output, the remote variant selection algorithm and will yield the appropriate action to be performed. There are two possibilities: Choice_response The Accept- headers contain sufficient information to make a choice on behalf of the user agent possible, and the best variant MAY be returned in a choice response. List_response The Accept- headers do not contain sufficient information to make a choice on behalf of the user agent possible. A list response MUST be returned, allowing the user agent to make the choice itself.3.3 Computing overall quality values As a first step in the remote variant selection algorithm, the overall qualities of the individual variants in the list are computed. The overall quality Q of a variant is the value Q = round5( qs * qt * qc * ql * qf ) where round5 is a function which rounds a floating point value to 5 decimal places after the point, and where the factors qs, qt, qc, ql, and qf are determined as follows.Holtman & Mutz Experimental [Page 3]RFC 2296 HTTP RVSA/1.0 March 1998 qs Is the source quality factor in the variant description. qt The media type quality factor is 1 if there is no type attribute in the variant description, or if there is no Accept header in the request. Otherwise, it is the quality assigned by the Accept header to the media type in the type attribute. Note: If a type is matched by none of the elements of an Accept header, the Accept header assigns the quality factor 0 to that type. qc The charset quality factor is 1 if there is no charset attribute in the variant description, or if there is no Accept-Charset header in the request. Otherwise, the charset quality factor is the quality assigned by the Accept-Charset header to the charset in the charset attribute. ql The language quality factor is 1 if there is no language attribute in the variant description, or if there is no Accept-Language header in the request. Otherwise, the language quality factor is the highest quality factor assigned by the Accept-Language header to any one of the languages listed in the language attribute. qf The features quality factor is 1 if there is no features attribute in the variant description, or if there is no Accept-Features header in the request. Otherwise, it is the quality degradation factor for the features attribute, see section 6.4 of [2]. As an example, if a variant list contains the variant description {"paper.html.en" 0.7 {type text/html} {language fr}} and if the request contains the Accept- headers Accept: text/html:q=1.0, */*:q=0.8 Accept-Language: en;q=1.0, fr;q=0.5 the remote variant selection algorithm will compute an overall quality for the variant as follows: {"paper.html.fr" 0.7 {type text/html} {language fr}} | | | | | | V V V round5 ( 0.7 * 1.0 * 0.5 ) = 0.35000Holtman & Mutz Experimental [Page 4]RFC 2296 HTTP RVSA/1.0 March 1998 With the above Accept- headers, the complete variant list {"paper.html.en" 0.9 {type text/html} {language en}}, {"paper.html.fr" 0.7 {type text/html} {language fr}}, {"paper.ps.en" 1.0 {type application/postscript} {language en}} would yield the following computations: round5 ( qs * qt * qc * ql * qf ) = Q --- --- --- --- --- ------- paper.html.en: 0.9 * 1.0 * 1.0 * 1.0 * 1.0 = 0.90000 paper.html.fr: 0.7 * 1.0 * 1.0 * 0.5 * 1.0 = 0.35000 paper.ps.en: 1.0 * 0.8 * 1.0 * 1.0 * 1.0 = 0.800003.4 Definite and speculative quality values A computed overall quality value can be either definite or speculative. An overall quality value is definite if it was computed without using any wildcard characters '*' in the Accept- headers, and without the need to use the absence of a particular Accept- header. An overall quality value is speculative otherwise. As an example, in the previous section, the quality values of paper.html.en and paper.html.fr are definite, and the quality value of paper.ps.en is speculative because the type application/postscript was matched to the range */*. Definiteness can be defined more formally as follows. An overall quality value Q is definite if the same quality value Q can be computed after the request message is changed in the following way: 1. If an Accept, Accept-Charset, Accept-Language, or Accept-Features header is missing from the request, add this header with an empty field. 2. Delete any media ranges containing a wildcard character '*' from the Accept header. Delete any wildcard '*' from the Accept-Charset, Accept-Language, and Accept-Features headers. As another example, the overall quality factor for the variant {"blah.html" 1 {language en-gb} {features blebber [x y]}} is 1 and definite with the Accept- headers Accept-Language: en-gb, fr Accept-Features: blebber, x, !y, *Holtman & Mutz Experimental [Page 5]RFC 2296 HTTP RVSA/1.0 March 1998 and Accept-Language: en, fr Accept-Features: blebber, x, * The overall quality factor is still 1, but speculative, with the Accept- headers Accept-language: en-gb, fr Accept-Features: blebber, !y, * and Accept-Language: fr, * Accept-Features: blebber, x, !y, *3.5 Determining the result The best variant, as determined by the remote variant selection algorithm, is the one variant with the highest overall quality value, or, if there are multiple variants which share the highest overall quality, the first variant in the list with this value. The end result of the remote variant selection algorithm is Choice_response if all of the following conditions are met a. the overall quality value of the best variant is greater than 0 b. the overall quality value of the best variant is a definite quality value c. the variant resource is a neighbor of the negotiable resource. This last condition exists to ensure that a security-related restriction on the generation of choice responses is met, see sections 10.2 and 14.2 of [2]. In all other cases, the end result is List_response. The requirement for definiteness above affects the interpretation of Accept- headers in a dramatic way. For example, it causes the remote algorithm to interpret the header Accept: image/gif;q=0.9, */*;q=1.0 as `I accept image/gif with a quality of 0.9, and assign qualityHoltman & Mutz Experimental [Page 6]RFC 2296 HTTP RVSA/1.0 March 1998 factors up to 1.0 to other media types. If this information is insufficient to make a choice on my behalf, do not make a choice but send the list of variants'. Without the requirement, the interpretation would have been `I accept image/gif with a quality of 0.9, and all other media types with a quality of 1.0'.4 Use of the algorithm This section discusses how user agents can use the remote algorithm in an optimal way. This section is not normative, it is included for informational purposes only.4.1 Using quality factors to rank preferences Using quality factors, a user agent can not only rank the elements within a particular Accept- header, it can also express precedence relations between the different Accept- headers. Consider for example the following variant list: {"paper.english" 1.0 {language en} {charset ISO-8859-1}}, {"paper.greek" 1.0 {language el} {charset ISO-8859-7}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -