Question

I'm determining a user's language/locale from the Accept-Language header, and was wondering if they could ever be passed out of order. I've written a php sort function to make sure they are in descending order, but if it's unnecessary, I'd like to remove it.

Example of proper order:

Accept-Language: fr-ca, fr; q=0.8, en-ca; q=0.6, en-us; q=0.4, en; q=0.2

Example of improper order:

Accept-Language: fr-ca, en; q=0.2, en-ca; q=0.6, en-us; q=0.4, fr; q=0.8

Was it helpful?

Solution

Yes, content negotiation values can be sent out of order.

HTTP/1.1 Specification doesn't define anything about ordering of values in Accept-* headers. So the order doesn't have any meaning for client's preference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top