HTTP Accept Header 含义 [英] HTTP Accept Header meaning

查看:39
本文介绍了HTTP Accept Header 含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当浏览器的 Accept 请求标头显示如下内容时:

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

这是否意味着 application/xmlapplication/xhtml+xmltext/html 都具有 的质量参数>0.9?

Does that mean that application/xml, application/xhtml+xml, and text/html all have a quality param of 0.9?

还是说application/xmlapplication/xhtml+xml有默认的(q=1)和text/htmlq=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.

推荐答案

不,如果 质量参数丢失 q=1.0 假定:

No, if the quality parameter is missing q=1.0 is assumed:

每个媒体范围可以后跟一个或多个接受参数,以q"参数开头,使用 qvalue 范围从 0 到 1(第 3.9 节)指示相对质量因子 […].默认值为 q=1.

Each media-range MAY be followed by one or more accept-params, beginning with the "q" parameter for indicating a relative quality factor […] using the qvalue scale from 0 to 1 (section 3.9). The default value is q=1.

所以给定的值被解释为:application/xml, application/xhtml+xml, and image/png首选媒体类型,但如果它们不存在,则发送 text/html 实体 (text/html;q=0.9),如果不存在存在,然后发送 text/plain 实体 (text/plain;q=0.8),如果不存在,则发送具有任何其他媒体类型的实体 (*/*;q=0.5)."

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)."

这篇关于HTTP Accept Header 含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆