Search code examples
httpnetwork-programminghttp-headersprotocols

Header Accept in HTTP


I have a problem with "Accept" header in http. I've writen a http client, and when I set "Accept: image/png" I can still read any file (like txt, html, etc). I think it shouldn't be possible when header "Accept" is set like above.

I tried to check how my Firefox behaves. I wrote "about:config" and I set "network.http.accept.default" as "image/png", and I can surf the net as usually.

Am I misunderstanding meaning of this header? I think that I should only be able to open files *.png.


Solution

  • As you suppose, setting Accept means that you can't accept others medias than these specified, and servers should return a 406 response code. It practice, servers don't implements correctly, and always send a response.

    All details are available in RFC 2616