willdurand / Negotiation

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

forcing quality for media ranges #51

Closed neural-wetware closed 9 years ago

neural-wetware commented 9 years ago

This code in Negotiator::parseHeader() isn't part of the standard, as far as I know.

if (self::CATCH_ALL_VALUE === $value) {
    $quality = 0.01;
} elseif ('*' === substr($value, -1)) {
    $quality = 0.02;
}

Should be removed?

willdurand commented 9 years ago

as far as I can remember, it is used to properly retrieve the right media type during the negotiation process. Thing is, there is no standard algorithm for that so... this is not really wrong per se. If we can get ride of this though, why not.

neural-wetware commented 9 years ago

I think the user-agent is supposed to set the quality for catchalls. Just like with any specific media type. Othewise it should default to 1.0.

You can do this, for example:

Accept: text/html; q=0.5, */*; q=0.6

For which a match of image/png will have q=0.6. Also,

Accept: text/html; q=0.5, */*

For which a match of image/png will have q=1.0.

This is my understanding of the RFC. I think forcing q to anything violates the spec.