我正在使用 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 范围标头“故意"加载部分文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!