diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/http/headers/accept | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/http/headers/accept')
-rw-r--r-- | files/zh-cn/web/http/headers/accept/index.html | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/files/zh-cn/web/http/headers/accept/index.html b/files/zh-cn/web/http/headers/accept/index.html new file mode 100644 index 0000000000..13e1fbaa34 --- /dev/null +++ b/files/zh-cn/web/http/headers/accept/index.html @@ -0,0 +1,85 @@ +--- +title: Accept +slug: Web/HTTP/Headers/Accept +translation_of: Web/HTTP/Headers/Accept +--- +<div>{{HTTPSidebar}}</div> + +<p><strong><code>Accept</code></strong> 请求头用来告知(服务器)客户端可以处理的内容类型,这种内容类型用<a href="/zh-CN/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME类型</a>来表示。借助<a href="/en-US/docs/Web/HTTP/Content_negotiation">内容协商机制</a>, 服务器可以从诸多备选项中选择一项进行应用,并使用 {{HTTPHeader("Content-Type")}} 应答头通知客户端它的选择。浏览器会基于请求的上下文来为这个请求头设置合适的值,比如获取一个CSS层叠样式表时值与获取图片、视频或脚本文件时的值是不同的。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">Header type</th> + <td>{{Glossary("Request header")}}</td> + </tr> + <tr> + <th scope="row">{{Glossary("Forbidden header name")}}</th> + <td>no</td> + </tr> + <tr> + <th scope="row">{{Glossary("Simple header", "CORS-safelisted request-header")}}</th> + <td>yes</td> + </tr> + </tbody> +</table> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">Accept: <MIME_type>/<MIME_subtype> +Accept: <MIME_type>/* +Accept: */* + +// Multiple types, weighted with the {{glossary("quality values", "quality value")}} syntax: +Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8</pre> + +<h2 id="指令">指令</h2> + +<dl> + <dt><code><MIME_type>/<MIME_subtype></code></dt> + <dd>单一精确的 <a href="/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME </a>类型, 例如<code>text/html</code>.</dd> + <dt><code><MIME_type>/*</code></dt> + <dd>一类 MIME 类型, 但是没有指明子类。 <code>image/*</code> 可以用来指代 <code>image/png</code>, <code>image/svg</code>, <code>image/gif</code> 以及任何其他的图片类型。</dd> + <dt><code>*/*</code></dt> + <dd>任意类型的 MIME 类型</dd> + <dt><code>;q=</code> (q因子权重)</dt> + <dd>值代表优先顺序,用相对<a href="/en-US/docs/Glossary/Quality_values">质量价值</a>表示,又称作权重。</dd> +</dl> + +<h2 id="示例">示例</h2> + +<pre>Accept: text/html + +Accept: image/* + +Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8 +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Title</th> + </tr> + <tr> + <td>{{RFC("7231", "Accept", "5.3.2")}}</td> + <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.headers.Accept")}}</p> + +<h2 id="参见">参见</h2> + +<ul> + <li>HTTP <a href="/en-US/docs/Web/HTTP/Content_negotiation">内容协商 </a></li> + <li>表示内容协商结果的消息头: {{HTTPHeader("Content-Type")}}</li> + <li>其他相似消息头: {{HTTPHeader("TE")}}, {{HTTPHeader("Accept-Encoding")}}, {{HTTPHeader("Accept-Charset")}}, {{HTTPHeader("Accept-Language")}}</li> +</ul> |