http标头ajax范围总是提供完整的网站

Jul*_*ian 1 javascript greasemonkey range http-headers

我尝试使用Range-header在Greasemonkey脚本中发送请求.请求的网站有点长,我知道我实际需要哪些部分,所以我想,而不是要求整个网站下载我可以请求必要的500字节来加快速度.

但是,Range: bytes=0-500总是给我完整的网站.我也试过了Content-Range: bytes=0-500,但是不起作用,Content-Length:500由于安全问题,不允许再设置它.

那么,有谁知道,为什么会这样?我正在使用Greasemonkey脚本:

 GM_xmlhttpRequest({
    method: 'GET',
    url: "http://colonel-strawberry.deviantart.com/",
     headers: {"Range": "bytes=0-500"}, 
    onload: function (responseDetails) {
      console.log(responseDetails);
    },
    onerror: function(responseDetails) {
      console.log("err:"+responseDetails);
    }
});
Run Code Online (Sandbox Code Playgroud)

使用response-header:

Date: Mon, 05 Nov 2012 17:11:42 GMT
Content-Encoding: gzip
Transfer-Encoding: chunked
P3P: policyref="/w3c/p3p.xml", CP="NOI DSP COR CURa OUR STP"
Connection: Keep-Alive
Server: Apache
Vary: Accept-Encoding
Content-Type: text/html
Cache-Control: private
Keep-Alive: timeout=45
Run Code Online (Sandbox Code Playgroud)

Que*_*tin 5

主机colonel-strawberry.deviantart.com似乎不支持字节范围请求.

您需要从支持它们的服务器请求数据.

(我通过比较首先curl -H "Range: bytes=50-60" $foo在哪里,然后在我控制的服务器上的URI来测试).$foohttp://colonel-strawberry.deviantart.com

注意HTTP规范:

服务器可以忽略Range标头.