Sinatra 1.1's support for byte-range requests (the 'Range:' header) in static files is welcome, but has some serious bugs:
Thanks for reporting. Will look into this tomorrow.
I don't have a patch ready yet, but the first bug can be fixed by replacing the first loop in StaticFile#each with:
while length > 0 && (buf = read([8192,length].min))
length -= buf.length
Found some more areas where the implementation does not match the RFC:
I hope this doesn't sound snarky, but I get the impression that whoever implemented this didn't actually read the specification? RFC 2616 is pretty long, but the sections that describe byte-range requests are only two pages or so.
Removed the patch for now, so it will no longer block a release.
Re-implemented ranges and sent a pull request: http://github.com/sinatra/sinatra/pull/95
Re-implement byte-range support for static files.
Correct handling of "Range:" request header. Replaces buggy implementation (480b1e8, 44ab090) that was recently backed out.
Closed by 9a01e3d.
NOTE: Does not yet support multiple ranges (e.g. "bytes=1-10,20-30") because that requires sending a multipart response, which is more complex than I want to get into now.
Signed-off-by: Konstantin Haase firstname.lastname@example.org