Interpretation Accept headers as assumed in IE and Webkit

I developed a web application that responds with data in the format specified by the client in the HTTP Accept Headers . Everything worked fine when using Firefox, but when I wanted to test my CSS / HTML on Chrome and IE, they both wanted to load the index page, as if it were an unknown type of content.

After some research, I found this article which says that IE sends a lot of crude Accept HTTP headers to it, among other things, a list of content types image/*at the very beginning.

This resulted in my web application trying to send the index page as image/jpeg.

So how do you know when to ignore and when to use Accept Headers?

+3
source share
2 answers

The best thing you can do is most likely apply your own server-side weight if there are types with the same weight in the accept header. Thus, if you have text / html and image / * both with the same q (or none) value, you can give preference to text / html by default.

+1
source

I would just keep a blacklist of programs that send explicitly broken Accept headers such as IE and Safari (according to the article). If the User-Agent header matches the blacklist, ignore the Accept header, otherwise not.

Accept IE , image/* , , HTML XHTML ( q). AFAIK, Accept .

0

Source: https://habr.com/ru/post/1717219/


All Articles