--- title: Accept slug: Web/HTTP/Headers/Accept translation_of: Web/HTTP/Headers/Accept ---
Accept
HTTP 請求標頭(以 MIME type 標示)會對伺服器告知用戶端可解讀的內容類型。伺服器可以透過 content negotiation 來選用可行的協定,並以 {{HTTPHeader("Content-Type")}} 標頭告知用戶端。針對本標頭,瀏覽器可以根據完成請求的脈絡,來決定適合的數值:像是擷取 CSS 時,給予的值就會和圖片、影像、腳本不一樣。
標頭類型 | {{Glossary("Request header")}} |
---|---|
{{Glossary("Forbidden header name")}} | no |
{{Glossary("CORS-safelisted request header")}} | 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 {{glossary("quality values", "quality value")}} syntax: Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8
<MIME_type>/<MIME_subtype>
text/html
。<MIME_type>/*
image/*
會配對到 image/png
, image/svg
, image/gif
和等圖片類型。*/*
;q=
(q-factor weighting)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
規範 | 標題 |
---|---|
{{RFC("7231", "Accept", "5.3.2")}} | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("http.headers.Accept")}}