willdurand / Negotiation

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

Question: */*;q=0.0 #29

Closed coreation closed 10 years ago

coreation commented 10 years ago

This piece of software works great, however in 1 case, I get something I wouldn't expect to have.

Situation:

accept header => /;q=0.0

So no formats are allowed, could be used in combination with some random formats as well, bottom-line is, the server can't respond with a format, and/or all other formats aren't good enough.

When I fill in my priorities using this library, I also put "/" in it to receive normal results that are provided by default in this library, such as xml or json.

Now when I let it evaluate, I receive a format, with a quality of 0. Shouldn't this return just NULL? If you ask getBestFormat, you just get a format that suits best, this should be NULL as well, going by the rule if no proper response can be sent (user agent wants a format we cannot provide, we "should" provide a 406. If you as a server want to reply with a 406, you'll have to ask for "getBest", then check if the quality is higher than 0 and return an error.

Was this the intentional behaviour in this situation? If so, this can be closed and I'll check with getQuality if I'll have to throw a 406 or not.

willdurand commented 10 years ago

mmh, I think I can add a check for this use case. It sounds good to me.