AJAX, Internet Explorer, MIME Types and HTTP Proxies
by Alistair Miles
This is a followup to the post I wrote regarding the “object required” error I ran into when testing an AJAX application in Internet Explorer … I’ve now got to the bottom of the mystery!
The immediate problem was indeed that my server application was, under certain circumstances, returning an HTTP response that did not have a “Content-Type” header set to “text/xml”. If the header is not set thus, Internet Explorer will not instantiate the responseXML member of the XMLHttpRequest object, leading to the “object required” error when you try to access members of the expected (but non-existent) XML response document.
The bug was ultimately within the server application, which failed to send the correct “Content-Type” HTTP header. I eventually found that the bug was in fact within a Filter that encoded the content of the HTTP response using GZIP if the client indicated that it could accept such an encoding. The bug only materialised when the client did not indicate that it could accept a GZIP encoding, otherwise the correct HTTP headers were sent. Furthermore, I found that IE6 indicates that it can accept GZIP encoding when connected directly to the internet, but when making requests through an HTTP proxy it does not issue an “Accept-Encoding” header at all. This was the reason why, when I fiddled with the HTTP proxy settings in IE, the bug sometimes disappeared.