Javascript Internet Explorer 7-10删除xhr/activex中的内容长度

Javascript Internet Explorer 7-10删除xhr/activex中的内容长度,javascript,internet-explorer,xmlhttprequest,Javascript,Internet Explorer,Xmlhttprequest,我有一个与以下问题非常相似的问题: 我正在尝试获取特定JS文件的文件大小,如下所示: var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); if (!req) { throw new Error('XMLHttpRequest not supported'); } req.open('HEAD', urlToScript, false);

我有一个与以下问题非常相似的问题:

我正在尝试获取特定JS文件的文件大小,如下所示:

var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
if (!req) {
    throw new Error('XMLHttpRequest not supported');
}
req.open('HEAD', urlToScript, false);
req.send(null);
var size = req.getResponseHeader('Content-Length');
size变量在ie<10中是空字符串,在ie 10中是
null
。该代码在FF或Chrome等其他浏览器上运行良好

仅当请求的内容被gzip压缩时,才会出现此问题

在IE中,如果使用
req.getAllResponseHeaders()打印标题,则标题缺少“内容长度”和“内容编码”:

Firefox 20可打印更多信息:

Server: Apache-Coyote/1.1
Content-Encoding: gzip
Vary: Accept-Encoding
Last-Modified: Wed, 03 Mar 2010 07:01:40 GMT
Expires: Thu, 10 Apr 2014 12:05:24 GMT
Cache-Control: public, max-age=31536000
Content-Type: text/javascript;charset=utf-8
Content-Length: 17669
Date: Wed, 10 Apr 2013 12:05:24 GMT
X-Cache: MISS from somewhere.com
Via: 1.1 somewhere.com:8001 (squid/2.7.STABLE9)
Connection: keep-alive
Proxy-Connection: keep-alive

我还尝试将“Content Type”设置为“application/javascript”,并手动设置“Accept Encoding”请求头。什么都没用。有什么想法吗?

是跨域HTTP请求吗?
Server: Apache-Coyote/1.1
Content-Encoding: gzip
Vary: Accept-Encoding
Last-Modified: Wed, 03 Mar 2010 07:01:40 GMT
Expires: Thu, 10 Apr 2014 12:05:24 GMT
Cache-Control: public, max-age=31536000
Content-Type: text/javascript;charset=utf-8
Content-Length: 17669
Date: Wed, 10 Apr 2013 12:05:24 GMT
X-Cache: MISS from somewhere.com
Via: 1.1 somewhere.com:8001 (squid/2.7.STABLE9)
Connection: keep-alive
Proxy-Connection: keep-alive