Subject: p2: section 5.3.2 (Accept header)

From: Osama Mazahir <[email-masked]>
Date: Thu, 9 May 2013 00:36:24 +0000

In section 5.3.1, the weight is defined as:

------------

     weight = OWS ";" OWS "q=" qvalue

     qvalue = ( "0" [ "." 0*3DIGIT ] )

            / ( "1" [ "." 0*3("0") ] )

------------

In section 5.3.2, the Accept header grammar is defined as:

------------

     Accept = #( media-range [ accept-params ] )

     media-range    = ( "*/*"

                      / ( type "/" "*" )

                      / ( type "/" subtype )

                      ) *( OWS ";" OWS parameter )

     accept-params  = weight *( accept-ext )

     accept-ext     = OWS ";" OWS token [ "=" word ]

------------

The grammar seems to imply that the weight is always the first parameter.  But then the example shows that the weight is not the first parameter (e.g. the level=2 case):

------------

     Accept: text/*;q=0.3, text/html;q=0.7, text/html;level=1,

             text/html;level=2;q=0.4, */*;q=0.5

------------

Which way is correct?

Thanks,

--Osama.

---

From: Mark Nottingham <[email-masked]>
Date: Thu, 9 May 2013 15:24:09 +1000

Hi Osama,

Note that the media-range grammar allows a parameter, separately from accept-params. This is because:

> The media-range can include media type parameters that are applicable to that range.
> 
> Each media-range might be followed by zero or more applicable media type parameters (e.g., charset), an optional "q" parameter for indicating a relative weight (Section 5.3.1), and then zero or more extension parameters. The "q" parameter is necessary if any extensions (accept-ext) are present, since it acts as a separator between the two parameter sets.

<https://svn.tools.ietf.org/svn/wg/httpbis/draft-ietf-httpbis/latest/p2-semantics.html#header.accept>

I.e., there's a difference parameters on the media-range itself (usually, defined by the media type itself) and the extensions to the Accept header value.

Cheers,

--
Mark Nottingham   http://www.mnot.net/