HTTP Accept Header的意思(HTTP Accept Header meaning)

系统教程 行业动态 更新时间:2024-06-14 16:57:18
HTTP Accept Header的意思(HTTP Accept Header meaning)

当浏览器的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.

最满意答案

否,如果缺少质量参数 q=1.0 :

每个媒体范围可以跟随一个或多个接受参数,从“q”参数开始,以使用q值从0到1(第3.9节)来指示相对品质因子[...]。 默认值为q = 1。

所以给定的值被解释为:“ application / xmlapplication / xhtml + xml ”和“ image / png”是首选的媒体类型,但如果不存在,则发送text / html实体( text/html;q=0.9 ),如果不存在,则发送文本/纯 text/plain;q=0.8 ( text/plain;q=0.8 ),如果不存在,则发送具有任何其他媒体类型的实体( */*;q=0.5 )。

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

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.

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

更多推荐

本文发布于:2023-04-12 20:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/96353ee4692f0240affc3d9553509d7b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Accept   HTTP   meaning   Header

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!