Thursday, May 20, 2010

XmlHttpRequest.getAllResponseHeaders and Content-Encoding in IE7 & IE8

A couple of weeks ago we tried to change how our Browserscope Network test for GZIP works and the other night we ran into something peculiar and unexpected - IE7 and IE8 strip the Content-Encoding header for GZIP responses if/when the browser has decoded the response (which it should have). Reading the spec for getAllResponseHeaders, it looks like the only headers which ought to potentially be stripped are Set-Cookie and Set-Cookie2.

The reason this was interesting/annoying is that we were trying to do something other than simply test whether the browser says it can handle GZIP responses (via the Accept-Encoding header) -  we wanted to see if Google App Engine was actually returning a GZIP compressed response, in this case for a static CSS file. Looking at the headers from a packet sniffer it was clear that the Content-Encoding header was coming down the wire, but then in JavaScript - it had disappeared. Amusingly, IE6 showed the Content-Encoding header as being present.

When a user-agent decodes a GZIP response do you think it should strip Content-Encoding header from getAllResponseHeaders()?

No comments: