Você está lendo a versão em inglês deste conteúdo porque ainda não há uma tradução para este idioma. Ajude-nos a traduzir este artigo!
The Accept
request HTTP header advertises which content types, expressed as MIME types, the client is able to understand. Using content negotiation, the server then selects one of the proposals, uses it and informs the client of its choice with the Content-Type
response header. Browsers set adequate values for this header depending on the context where the request is done: when fetching a CSS stylesheet a different value is set for the request than when fetching an image, video or a script.
Header type | Request header |
---|---|
Forbidden header name | no |
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. |
Syntax
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, image/webp, */*;q=0.8
Directives
<MIME_type>/<MIME_subtype>
- A single, precise MIME type, like
text/html
. <MIME_type>/*
- A MIME type, but without any subtype.
image/*
will matchimage/png
,image/svg
,image/gif
and any other image types. */*
- Any MIME type
;q=
(q-factor weighting)- Any value used is placed in an order of preference expressed using relative quality value called the weight.
Examples
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
Specifications
Specification | Title |
---|---|
RFC 7231, section 5.3.2: Accept | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context |
Browser compatibility
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.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Accept | Chrome Full support Yes | Edge Full support Yes | Firefox
Full support
Yes
| IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android
Full support
Yes
| Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- See implementation notes.
- See implementation notes.
See also
- HTTP content negotiation
- Header with the result of the content negotiation:
Content-Type
- Other similar headers:
TE
,Accept-Encoding
,Accept-Charset
,Accept-Language