Can I use the HTTP range header to load partial files “on purpose”?

空扰寡人 提交于 2019-12-28 02:39:26

问题


I'm playing around with the HTTP range header (specs).

From what I understand I can set byte ranges of files ala

0-199/2000
200-499/2000
500-799/2000
etc

Question:
Say I only want to access certain ranges of a file, would it be possible to specify these ranges and then work with the "incomplete" data I received? I'm playing around with filtering a large log file, so I'm curious if something like this would work.

Thanks for inputs!


回答1:


You are right the link which you posted in the comment would be probably the best approche. As your question sounded interesting i tried it out. You probably did it, but here is an snippet(for other that may come looking)

var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","data.dat",false);
xmlhttp.setRequestHeader("Range", "bytes=100-200");
xmlhttp.send();
console.info(xmlhttp); //--> returns only the partial content
// Tested on Win7 with chrome 46+


来源:https://stackoverflow.com/questions/15200266/can-i-use-the-http-range-header-to-load-partial-files-on-purpose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!