我是否可以使用HTTP范围标头“有目的地”加载部分文件? [英] Can I use the HTTP range header to load partial files "on purpose"?
问题描述
我正在使用HTTP范围标题(规范) 。
I'm playing around with the HTTP range header (specs).
根据我的理解,我可以设置文件的字节范围ala
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.
感谢您的投入!
推荐答案
你是对的,你在评论中发布的链接可能是最好的方法。当你的问题听起来很有趣时,我试了一下。你可能做到了,但这里是一个片段(对于其他可能会看到的)
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+
这篇关于我是否可以使用HTTP范围标头“有目的地”加载部分文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!