RequestHeaders⾥⾯的Accept属性
例⼦:
Accept:text/html,application/xhtm +xml,application/xml;q=0.9,image/webp,*/*;q=0.8
逐鹿中原的意思Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:zh-CN,zh;q=0.8
Connection:keep-alive
q=0.9: q:表⽰优先权,先接受那个类型。
这个Accept 头属性能被⽤在浏览器响应能接受的media 类型。
The "Accept" header field can be ud by ur agents to specify respon media types that are acceptable.
这个“Accept” 头属性能被浏览器⽤来指定响应的media 类型,表⽰⾃⼰可以接受的类型。
便民服务站Accept header fields can be ud to indicate that the request is specifically limited to a small t of desired types,
as in the ca of a request for an in-line image.
Accept = #( media-range [ accept-params ])
media-range = ( "*/*":所有类型
/ ( type "/""*" ) :type 类型⼦类型
/ ( type "/"subtype ) type/type的⼦类型
) *( OWS ";"OWS parameter )
accept-params = weight *( accept-ext )
accept-ext = OWS ";" OWS token ["=" ( token / quoted-string ) ]
The asterisk "*" character is ud to group media types into ranges,
with "*/*" indicating all media types and "type/*" indicating all subtypes of that type.
The media-range can include media type parameters that are applicable to thatrange.
Each media-range might be followed by zeroor more applicable media type parameters (e.g., chart), an optional"q" parameter for indicating a relative weight (), and then zero or more
十个月宝宝发育标准extension parameters.
The "q" parameter is necessary if any extensions (accept-ext) are prent, since it acts as a parator
between the two parameter ts.
q 参数是必要的,如果⼀些扩展是出现了,因为他在两个参数集⾥⾯起作⽤。
Note: U of the "q" parameter name to parate media type parameters from Accept extension parameters is due to historical practice.
注:使⽤q参数把media 类型参数和可接受的扩展参数相分离是由于历史的实践。
Although this prevents any media type parameter named "q" from being ud with a media range,
西陵峡
尽管阻⽌命名q的⼀些media 类型参数?不在⼀个media 范围⾥使⽤。命名q的⼀些media 类型参数:不知道是哪些media 类型命名了?
such an event is believed to be unlikely given the lack of any"q" parameters in the IANA media type registry and the rare usage of any media type parameters in Accept.
Future media types are discouraged from registering any parameter named"q".
The example
Accept: audio/*; q=0.2, audio/basic
is interpreted as "I prefer audio/basic, but nd me any audio type:
我更喜欢⾳频/basic,但却给我任何⾳频类型.
if it is the best available after an 80% mark down in quality.在质量上下降80%后,如果它是最好的可利⽤的
A request without any Accept header field implies that the ur agent will accept any media type in respon.
⼀个请求没有任何的Accept 头属性暗⽰浏览器可以接受任何类型回应。
If the header field is prent in a request and none of the available reprentations for the respon have a media type that is listed as acceptable,
如果头属性出现在⼀个request中,但是tomcat 没有这样类型回应,将送⼀个406的回应或是忽略头属性,好像它不受内容的约束。
夏季饮品the origin rver can either honor the header field by nding a 406 (Not Acceptable) respon or disregard the header field by treating the respon as if it is not subject to content negotiation.
A more elaborate example is
Accept: text/plain; q=0.5, text/html,
text/x-dvi; q=0.8, text/x-c
Verbally, this would be interpreted as"text/html and text/x-c are the equally preferred media types, but if they do not exist, then
⼝头上,这个将被解释作为 text/html and text/x-c 是相等更好的media 类型,但是如果他们不存在,送⼀个 text/x-dvi 表⽰,如果这个不存在,送⼀个text/plain 表⽰
nd the text/x-dvi reprentation, and if that does not exist, nd the text/plain reprentation".
Media ranges can be overridden by more specific media ranges or specific media types.
Media 范围能被更具体的media 范围 或具体的media 类型重写。
If more than one media range applies to a given type, the most specific reference has precedence.
如果 多个media 范围应⽤到⼀个给定的类型, 最具体的引⽤具有优先权。
For example,
Accept: text/*, text/plain,text/plain;format=flowed, */*
有下⾯的优先级:
1. text/plain;format=flowed
2. text/plain
澳洲绿卡怎么拿
3. text/*
4. */*
The media type quality factor associated with a given type is determined by finding the media range with the highest precedence缺少发现美的眼睛
that matches the type.
media type的quality值和⼀个给定类型相关联,这个类型是⾸先查找⼀个media 的范围,取最⾼优先权的类型。
For example,
Accept: text/*;q=0.3, text/html;q=0.7,text/html;level=1,text/html;level=2;q=0.4, */*;q=0.5
关联如下:
+-------------------+---------------+
幼儿积食
| Media Type | Quality Value |
+-------------------+---------------+
| text/html;level=1 | 1 |
| text/html | 0.7 |
| text/plain | 0.3 |
| image/jpeg | 0.5 |
| text/html;level=2 | 0.4 |
| text/html;level=3 | 0.7 |
+-------------------+---------------+
Note: A ur agent might be provided with a default t of quality values for certain media ranges.
However, unless the ur agent is a clod system that cannot interact with other rendering agents, this default t ought to be configurable by the ur.