• December 22, 2024

Http Request Header Accept

Accept - HTTP - MDN Web Docs

Accept – HTTP – MDN Web Docs

The Accept request HTTP header indicates which content types, expressed as MIME types, the client is able to understand. The server uses content negotiation to select one of the proposals and informs the client of the choice with the Content-Type response header. Browsers set required values for this header based on the context of the request. For example, a browser uses different values in a request when fetches a CSS stylesheet, 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: 0x00-0x1F (except 0x09 (HT)),
“():<>? @[\]{}, and 0x7F (DEL).
SyntaxAccept: /
Accept: /*
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
/
A single, precise MIME type, like text/html.
/*
A MIME type, but without a subtype. image/* corresponds to image/png, image/svg, image/gif, and other image types.
*/*
Any MIME type;q= (q-factor weighting)
A value used is placed in an order of preference expressed using a relative quality value called the weight.
ExamplesAccept: text/html
Accept: image/*
// General default
// Default for navigation requests
Accept: text/html, application/xhtml+xml, application/xml;q=0. 9, */*;q=0. 8
SpecificationsSpecificationHypertext Transfer Protocol (HTTP/1. 1): Semantics and Content (HTTP/1. 1)# ceptBrowser compatibilityBCD tables only load in the browserSee also
HTTP content negotiation
List of default Accept values
A header with the result of the content negotiation: Content-Type
Other similar headers: TE, Accept-Encoding, Accept-Language
Accept - HTTP - MDN Web Docs

Accept – HTTP – MDN Web Docs

The Accept request HTTP header indicates which content types, expressed as MIME types, the client is able to understand. The server uses content negotiation to select one of the proposals and informs the client of the choice with the Content-Type response header. Browsers set required values for this header based on the context of the request. For example, a browser uses different values in a request when fetches a CSS stylesheet, 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: 0x00-0x1F (except 0x09 (HT)),
“():<>? @[\]{}, and 0x7F (DEL).
SyntaxAccept: /
Accept: /*
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
/
A single, precise MIME type, like text/html.
/*
A MIME type, but without a subtype. image/* corresponds to image/png, image/svg, image/gif, and other image types.
*/*
Any MIME type;q= (q-factor weighting)
A value used is placed in an order of preference expressed using a relative quality value called the weight.
ExamplesAccept: text/html
Accept: image/*
// General default
// Default for navigation requests
Accept: text/html, application/xhtml+xml, application/xml;q=0. 9, */*;q=0. 8
SpecificationsSpecificationHypertext Transfer Protocol (HTTP/1. 1): Semantics and Content (HTTP/1. 1)# ceptBrowser compatibilityBCD tables only load in the browserSee also
HTTP content negotiation
List of default Accept values
A header with the result of the content negotiation: Content-Type
Other similar headers: TE, Accept-Encoding, Accept-Language
Accept - HTTP - MDN Web Docs

Accept – HTTP – MDN Web Docs

The Accept request HTTP header indicates which content types, expressed as MIME types, the client is able to understand. The server uses content negotiation to select one of the proposals and informs the client of the choice with the Content-Type response header. Browsers set required values for this header based on the context of the request. For example, a browser uses different values in a request when fetches a CSS stylesheet, 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: 0x00-0x1F (except 0x09 (HT)),
“():<>? @[\]{}, and 0x7F (DEL).
SyntaxAccept: /
Accept: /*
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
/
A single, precise MIME type, like text/html.
/*
A MIME type, but without a subtype. image/* corresponds to image/png, image/svg, image/gif, and other image types.
*/*
Any MIME type;q= (q-factor weighting)
A value used is placed in an order of preference expressed using a relative quality value called the weight.
ExamplesAccept: text/html
Accept: image/*
// General default
// Default for navigation requests
Accept: text/html, application/xhtml+xml, application/xml;q=0. 9, */*;q=0. 8
SpecificationsSpecificationHypertext Transfer Protocol (HTTP/1. 1): Semantics and Content (HTTP/1. 1)# ceptBrowser compatibilityBCD tables only load in the browserSee also
HTTP content negotiation
List of default Accept values
A header with the result of the content negotiation: Content-Type
Other similar headers: TE, Accept-Encoding, Accept-Language

Frequently Asked Questions about http request header accept

What is accept in HTTP header?

The Accept request HTTP header indicates which content types, expressed as MIME types, the client is able to understand. The server uses content negotiation to select one of the proposals and informs the client of the choice with the Content-Type response header.Oct 3, 2021

What is the use of accept and content-type header in HTTP request?

Accept header is used by HTTP clients to tell the server which type of content they expect/prefer as response. Content-type can be used both by clients and servers to identify the format of the data in their request (client) or response (server) and, therefore, help the other part interpret correctly the information.Mar 1, 2016

Is HTTP Accept header mandatory?

Accept isn’t mandatory; the server can (and often does) either not implement it, or decides to return something else.Nov 22, 2015

Leave a Reply