?
This document uses PHP Chinese website manual Release
Accept
請求的 HTTP 標頭通告了內(nèi)容類型,并表示為 MIME 類型,客戶端是能夠理解的。使用內(nèi)容協(xié)商,服務器然后選擇其中一個提議,使用它并通過Content-Type
響應頭通知客戶它的選擇。瀏覽器根據(jù)請求完成的上下文為此標頭設置足夠的值:在獲取 CSS 樣式表時,為請求設置的值與獲取圖像,視頻或腳本時的值不同。
Header type | Request header |
---|---|
Forbidden header name | no |
CORS-safelisted request-header | yes |
Accept: <MIME_type>/<MIME_subtype>Accept: <MIME_type>/* Accept: */*// Multiple types, weighted with the quality value syntax:Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8
<MIME_type>/<MIME_subtype>
一個精確的 MIME 類型,比如text/html
。
<MIME_type>/*
MIME 類型,但沒有任何子類型。
image/*
將匹配image/png
,image/svg
,image/gif
和任何其他的圖像類型。
*/*
任何 MIME 類型。
;q=
(q因子權重)使用的任何值都將按照使用稱為權重的相對質(zhì)量值的優(yōu)先順序排列。
Accept: text/html Accept: image/* Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8
Specification | Title |
---|---|
RFC 7231, section 5.3.2: Accept | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context |
Feature | Chrome | Firefox | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |