开发者

Why use quality values in the HTTP Accept-Language header?

In HTTP, the Accept-Language request header looks like this:

Accept-Language: da, en-gb;q=0.8, en;q=0.7

Why were the quality values (q=...) included in the HTTP specification? Couldn't one sor开发者_Python百科t the languages by quality, pick an arbitrary order for languages with the same quality, and leave out any languages with q=0?


Interesting question.

The discussion of how this feature came to be is probably buried somewhere in the mailing list archives, for which I could not find a valid link. Your example is not the only problematic one. What is a server to with "fr; q=1.0, en; q=1.0" if it supports both languages. Serve the french because it is first? What about "fr, en; q=1.0"?

Seems to me that an ordered list of language preferences would be a better fit for the problem than the current weighted (and maybe sorted) list. There are too many edge cases where the spec is mum about the expected behavior from an implementation.

At least (some of) the contributors to the spec agree this feature is far from perfect (Key Differences between HTTP/1.0 and HTTP/1.1 - Paper Presented at The Eighth International World Wide Web Conference):

"Because the content-negotiation mechanism allows qvalues and wildcards, and expresses variation across many dimensions (language, character-set, content-type, and content-encoding) the automated choice of the ``best available'' variant can be complex and might generate unexpected outcomes. These choices can interact with caching in subtle ways; see the discussion in Section 3.4.

Content negotiation promises to be a fertile area for additional protocol evolution. For example, the HTTP working group recognized the utility of automatic negotiation regarding client implementation features, such as screen size, resolution, and color depth. The IETF has created the Content Negotiation working group to carry forward with work in the area."

In short I have no real answer but hopefully a participant in the specification process pipes in.


Keep in mind that Quality Values are used for many other (Accept-*) headers, so while it may not make much sense in context of Accept-Language and feel overcomplicated for selecting languages, the same universal concept is being used for MIME-types (including wildcards for whole groups) and much more, so don't judge just based solely on how it fits the user language selection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜