IE XMLhttpRequest getResponseHeader ("Content-Length") missing when sending Content-Encoded

Why won't IE let me see the Content-Length header with getResponseHeader() ?

I know headers are being sent; I see them with Wireshark. IE just won't let me get them.

If the Content-Encoding header is not sent, regardless of whether the content is gzipped or not, I can get them just fine.

Code example:

  function getXMLHttpRequest() { if (window.XMLHttpRequest) { return new window.XMLHttpRequest; } else { try { return new ActiveXObject("MSXML2.XMLHTTP.3.0"); } catch (ex) { return null; } } } function handler() { if (oReq.readyState == 4 /* complete */) { if (oReq.status == 200) { // this alert will be missing Content-Length // and Content-Encoding if Content-Encoding is sent. alert(oReq.getAllResponseHeaders()); } } } var oReq = getXMLHttpRequest(); if (oReq != null) { oReq.open("GET", "http://www.example.com/gzipped/content.js", true); oReq.onreadystatechange = handler; oReq.send(); } else { window.alert("AJAX (XMLHTTP) not supported."); } 
+4
source share
1 answer

You may notice that many missing headers, including the ones that are most meaningful to you: "Content-Encoding: deflate"

This is because after unzip IE generates fake headers according to MVP: https://social.msdn.microsoft.com/Forums/ie/en-US/b2cc04ca-1d4e-4381-9750-361128987e2f/http-response-header- variable-returns-null-in-ie-11? forum = iewebdevelopment

0
source

All Articles