Accept
Accept
HTTP 請求標頭(以 MIME type 標示)會對伺服器告知用戶端可解讀的內容類型。伺服器可以透過 content negotiation (en-US) 來選用可行的協定,並以 Content-Type
標頭告知用戶端。針對本標頭,瀏覽器可以根據完成請求的脈絡,來決定適合的數值:像是擷取 CSS 時,給予的值就會和圖片、影像、腳本不一樣。
標頭類型 | Request header (en-US) |
---|---|
Forbidden header name (en-US) | no |
CORS-safelisted request header (en-US) | yes, with the additional restriction that values can't contain a CORS-unsafe request header byte: "():<>?@[\]{} , Delete, Tab and control characters: 0x00 to 0x19. |
語法
Accept: <MIME_type>/<MIME_subtype> Accept: <MIME_type>/* Accept: */* // Multiple types, weighted with the quality value (en-US) syntax: Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8
指令
<MIME_type>/<MIME_subtype>
-
一個精確的 MIME type,例如
text/html
。 <MIME_type>/*
-
一個不指定子類的 MIME type。
image/*
會配對到image/png
,image/svg
,image/gif
和等圖片類型。 */*
-
所有 MIME type
;q=
(q-factor weighting)-
Any value used is placed in an order of preference expressed using relative quality value (en-US) called the weight.
示例
Accept: text/html Accept: image/* // General default Accept: */* // Default for navigation requests Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8
規範
Specification |
---|
HTTP Semantics # field.accept |
瀏覽器相容性
BCD tables only load in the browser
參見
- HTTP content negotiation (en-US)
- Header with the result of the content negotiation:
Content-Type
- 類似標頭:
TE
(en-US),Accept-Encoding
(en-US),Accept-Charset
(en-US),Accept-Language
(en-US)