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!
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!
Share Improve this question asked Mar 4, 2013 at 11:15 frequentfrequent 28.5k61 gold badges187 silver badges336 bronze badges 4- 1 Seems to me like the perfect case to use that header. w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2 – Supericy Commented Mar 4, 2013 at 11:22
- Yeah, I also think it was developed exactly for such cases. Haven't you tried if that works? – VisioN Commented Mar 4, 2013 at 11:28
- As has already been mentioned, that's exactly what range requests are for. This is generally how media "streaming" is accomplished via HTTP. – user895378 Commented Mar 4, 2013 at 13:46
- yes. I'm thinking more into using this as a filter of a large file, similar to what is described here. Would be nice if it was possible to not only filter "from-to" like this. – frequent Commented Mar 4, 2013 at 13:48
1 Answer
Reset to default 18You are right, the link which you posted in the comment would be probably the best approach. As your question sounded interesting i tried it out. You probably did it also, 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+
Watch-out: the web-server has to support this Request Header Range, for it to work.