Search code examples
http-headershttp-1.1http-accept-header

Are weight values required in an Accept Header with multiple values?


Per the spec, the HTTP Accept header can have multiple values, like so:

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

Source

My question is this: do Accept headers with multiple values need to have at least one weight? Or are they still valid if none of the content types have a weight?

In other words, would this Accept header still be valid according to the spec?

Accept: text/html, application/xhtml+xml, application/xml, */*

Thanks a bunch in advance!


Solution

  • The quality values are optional, but then each entry has an implied quality value of 1.

    https://developer.mozilla.org/en-US/docs/Glossary/Quality_values

    The importance of a value is marked by the suffix ';q=' immediately followed by a value between 0 and 1 included, with up to three decimal digits, the highest value denoting the highest priority. When not present, the default value is 1.