Accept

The HTTP Accept request header is included in an HTTP message to indicate the types of content that the client can understand.

Usage

The HTTP Accept request header is part of the Content Negotiation process and specifies which MIME types the client is able to understand during communication with the server. Internet browsers such as Chrome, Firefox, and Microsoft Edge set values for this based on the type of HTTP request.

There are several ways that this HTTP header can be used, as follows:

Accept: <MIME-type>/<MIME-subtype>

This specifies a particular content type, such as text/html or image/jpg.

Accept: <MIME-type>/*

This specifies a general type, without including the detail required for particular subtypes. For example, text/* informs the server that the client is willing to accept all text documents, whether they are text/plain, text/html, or otherwise.

Accept:*/*

This HTTP header indicates that any type of content is allowed.

Multiple types and q-factor weighting

Several types can be specified on a single line, and the preference of one over another can be weighted using the q-factor. The q-factor, included using the suffix ;q=, states that the client is willing to accept this set at a relative priority. If no priority is included then the default value of 1.0 is used.

Example

In this example, several acceptable types are indicated by the same HTTP header.

Accept: text/html, text/plain;q=0.9, text/*;q=0.8, */*;q=0.7

This HTTP Accept request header indicates that text/html resources are given priority 1.0, whereas text/plain content has a priority of 0.9. Less specific text resources have a priority of 0.8, and the remainder is considered equal with a priority of 0.7.

Note

If two types are of the same priority but have different specificity, then deference is given to the more specific type. For instance, if text/html and text/* both have a priority of 1.0, then text/html is selected.

Takeaway

The HTTP Accept request header is used by clients to inform servers concerning types of content they can understand, and relatively which types they prefer to receive.

See also

Last updated: June 2, 2022