willdurand / Negotiation

Content Negotiation tools for PHP.
https://williamdurand.fr/Negotiation/
MIT License
1.41k stars 62 forks source link

Precedence over wildcards #54

Closed jaytaph closed 9 years ago

jaytaph commented 9 years ago

When given the following header:

Accept: text/xml,text/*;q=0.6,application/pdf;q=0.6

it should prioritize application/pdf over text/html, as application/pdf is matched more specifically. This is taken from RFC 2616, chapter:

If more than one media range applies to a given type, the most specific reference has precedence.

Right now, it prefers text/html.

willdurand commented 9 years ago

I don't think application/pdfis more specific than text/xml according to the sentence you pasted.

jaytaph commented 9 years ago

No, text/xml isnt... but I said: text/html, which is

willdurand commented 9 years ago

In the priorities?

neural-wetware commented 9 years ago

In your example there is not more than one media range applying to a given type. So, the condition quoted from the RFC is not satisfied.

text/* applies to test/html and application/pdf applies to application/pdf. Only one media range applies to each of these server priorities.

Since they have the same q value, the choice comes down to server priority.

jaytaph commented 9 years ago

Ah that actually might make sense. Thanks!