TyAnthoney
TyAnthoney

Reputation: 288

HTTP Content Negotiation with accept

Could someone help me clarify what the number values of the q parameter represent. I know that the values are used to select your preference but what I do not understand is how the numbers are used. For example in the below code would my preference remain the same if I were to use application/json;q=0.3,*/*,q=0.2?

headers.append('Accept', 'application/json;q=0.9,*/*;q=0.8');

Upvotes: 0

Views: 199

Answers (1)

SilverlightFox
SilverlightFox

Reputation: 33538

It depends on the server application.

Your first statement is saying "I will accept json if you can guarantee 30% quality, but if not I can accept anything at 20% quality".

Your second is saying "I will accept json if you can guarantee 90% quality, but if not I can accept anything at 80% quality".

However, the application could take that to mean "provide json if you can, otherwise anything else".

Official spec here.

For more details see this question.

Upvotes: 1

Related Questions