HTTP Accept 标头含义
当浏览器的 Accept 请求标头显示如下内容时:
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
这是否意味着 application/xml
、application/xhtml+xml
和 text/html
> 所有的质量参数都是0.9
?
或者这是否意味着 application/xml
和 application/xhtml+xml
具有默认值 (q=1
) 和 text/html
有 q=0.9
参数吗?
我假设是前者,但希望有人更明确地知道。
When a browser's Accept request header says something like the following:
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Does that mean that application/xml
, application/xhtml+xml
, and text/html
all have a quality param of 0.9
?
Or does it mean that application/xml
and application/xhtml+xml
have the default (q=1
) and text/html
has the q=0.9
param?
I'm assuming the former, but was hoping someone knew more definitively.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
否,如果缺少质量参数
q=1.0 假设:
因此给定值应解释为:“application/xml、application/xhtml+xml 和 image/png 是首选媒体类型,但如果它们不存在,则发送 text/html 实体 (
text/html;q=0.9
),如果不存在,则发送 text/plain 实体 (text/plain;q=0.8
),如果该实体不存在,则发送任何其他媒体类型的实体 (*/*;q=0.5
)。”No, if the quality parameter is missing
q=1.0
is assumed:So the given value is to be interpreted as: “application/xml, application/xhtml+xml, and image/png are the preferred media types, but if they don’t exist, then send the text/html entity (
text/html;q=0.9
), and if that doesn’t exist, then send the text/plain entity (text/plain;q=0.8
), and if that doesn’t exist, send an entity with any other media type (*/*;q=0.5
).”口头上,这将被解释为“application/xml、application/xhtml+xml 和 image/png 是首选媒体类型,但如果它们不存在,则发送 text/html 实体,如果不存在,则发送文本/纯文本实体,如果仍然不存在,请发送任何其他媒体类型的实体。”
Verbally,this would be interpreted as "application/xml,application/xhtml+xml and image/png are the preferred media types,but if they do not exist,then send the text/html entity,and if that does not exist,send the text/plain entity,if that still does not exist,send an an entity with any other media type."