31

I have made a http request using Firefox.Now the request header shows the following:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

But curious to know what is q=0.9,*/*;q=0.8

3

4 Answers 4

26

Each media-range MAY be followed by one or more accept-params, beginning with the "q" parameter for indicating a relative quality factor. The first "q" parameter (if any) separates the media-range parameter(s) from the accept-params. Quality factors allow the user or user agent to indicate the relative degree of preference for that media-range, using the qvalue scale from 0 to 1. The default value is q=1

The information is available here

A nice explanation can be found here as well.

0
19

The Accept header list is first split at , then at ; for additional parameters per entry. So, the list in your example splits down to text/html, application/xhtml+xml, application/xml;q=0.9 and */*;q=0.8. The q= parameter on each entry indicates to the server the degree of preference for that media-type. It defaults to its maximum value of 1, if it is missing (like in the first 2 entries). The last entry of */*;q=0.8 indicates to the server, that eventually any content-type would be acceptable but would be less preferable than the others listed. Otherwise, the server might decide to send no content at all, because the client would not "accept" it anyway.

3

The Q value is always a number from zero to one and it represents the relative quality value. The default Q value is 1.0.

So something with a Q value of 0.9 is more preferred than something with a Q value of 0.6.

2

To add to @Robin479's correct answer, the accept header in the question is equivalent to,

Accept:
text/html;q=1,
application/xhtml+xml;q=1,
application/xml;q=0.9,
*/*;q=0.8

NOTE: The new line characters are just for better readability.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.