Accept: (Request)

Other topics

Remarks:

The content types are MIME types (ie text/html) separated by comma with an optional quality factor (using a ;q=) that is used the clients preference for using this type. The quality factor has a value from 0 to 1 with the higher the number the more preference for that type.

If the server can't find an acceptable type to reply with then it should send a 406 (not acceptable) response.

HTML only type

Request:"http://example.com"

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client will accept Content-Types of text/html

Match all text types

Request:"http://example.com"

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client will accept Content-Types of any of the text/* types of MIME types. For example text/html, text/plain, text/css.

text/html and application/xml with a preference text/html

Request:"http://example.com"

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html;q=1.0,application/xml;q=0.9
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client will accept Content-Types of text/html and application/xml but it prefers text/html

Preference for one type over another

Request:"http://example.com"

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

The client will accept all types of Content-Types but prefers text/html and application/xml

Syntax:

  • Accept: MIMEType/MIMESubtype;QualityFactor
  • Accept: MIMEType/MIMESubtype;QualityFactor, MIMEType/MIMESubtype;QualityFactor, ...

Parameters:

ParameterDescription
MIMETypeThe first half of the mime type. This can also be a */* for all types
MIMESubtypeThe second half of the mime type or a * for all sub types (ie image/*)
QualityFactorThe quality factor in the format ;q=0.8 (optional)

Contributors

Topic Id: 10614

Example Ids: 31853,31854,31855,31856

This site is not affiliated with any of the contributors.