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

查看:1464
本文介绍了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 / xml application / xhtml + xml text / html 所有质量参数都是 0.9

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

或者是否意味着 application / xml application / xhtml + xml 具有默认值( q = 1 )和 text / html q = 0.9 param?

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 :


每个媒体范围可以跟随一个或多个accept-params , 开始使用q参数来指示使用从0到1的q值标度的相对品质因数[...](第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 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天全站免登陆