Quality values / 质量价值
Quality values, or q-values and q-factors, are used to describe the order of priority of values in a comma-separated list. It is a special syntax allowed in some HTTP headers and in HTML. The importance of a value is marked by the suffix ';q=' immediately followed by a value between 0 and 1 included, with up to three decimal digits, the highest value denoting the highest priority. When not present, the default value is 1.
质量价值亦称作q值,其与q因子以逗号分隔的方式来描述值的优先级顺序,是HTTP 消息头以及HTML中的特殊语法。值的重要性以一种后缀表示:';q='。该后缀紧接0到1间的值(值可达小数点后三位),最高值表明最高优先级。无此后缀时,默认值为1。
Examples
示例
The following syntax
以下语法
1 | text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 |
indicates the order of priority:
表明优先级先后顺序:
| Value 值 | Priority 优先级 |
|---|---|
text/html and application/xhtml+xml |
1.0 |
application/xml |
0.9 |
*/* |
0.8 |
If there is no priority defined for the first two values, the order in the list is irrelevant. Nevertheless, with the same quality, more specific values have priority over less specific ones:
如果前面这两个值未定义优先级,值的顺序并不重要。然而,q值相同时,值越具体,其优先级越高。
1 | text/html;q=0.8,text/*;q=0.8,*/*;q=0.8 |
| Value 值 | Priority 优先级 |
|---|---|
text/html |
0.8 (but totally specified) |
text/* |
0.8 (partially specified) |
*/* |
0.8 (not specified) |
Some syntax, like the one of Accept, allow additional specifiers like text/html;level=1. These increase the specificity of the value. Their use is extremely rare.
像 Accept消息头的语法可以有额外的标记,比如text/html;level=1。这使值更具体,不过该用法不常见。
Browser-specific information
浏览器信息
Firefox
火狐
Starting with Firefox 18, the quality factor values are clamped to 2 decimal places. They used to be clamped to only 1 decimal place in earlier versions (bug 672448).
从Firefox 18开始,质量因子的值可达小数点后二位(之前的版本只能达小数点后一位)。(bug 672448)
More information
更多
- HTTP headers using q-values in their syntax:
Accept,Accept-Charset,Accept-Language,Accept-Encoding,TE. - 使用q值的HTTP消息头:
Accept、Accept-Charset、Accept-Language、Accept-Encoding和TE。