我尝试使用 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);
}
});
带有响应头:
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