Single range support

We now support single part ranges, as per:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests#Single_part_ranges

Multi-part ranges are not implemented because there have been far too
many bugs in this area.

It interacts with compression by selecting a byte range from the
compressed stream. Since the compressed stream is fixed, the results are
consistent.
This commit is contained in:
Laurence Withers 2019-10-09 13:04:07 +01:00
commit f7cd22f633
2 changed files with 84 additions and 13 deletions

View file

@ -10,7 +10,7 @@ support for:
- brotli, if you have the external compression binary available at pack time
- does not yet support Transfer-Encoding, only Accept-Encoding/Content-Encoding
- etags
- ranges (TODO)
- ranges
The workflow is as follows:
- (optional) build YAML file describing files to serve
@ -18,3 +18,13 @@ The workflow is as follows:
- create `htpack.Handler` pointing at .htpack file
The handler can easily be combined with middleware (`http.StripPrefix` etc.).
## Range handling notes
Too many bugs have been found with range handling and composite ranges, so the
handler only accepts a single range within the limits of the file. Anything
else will be ignored.
The interaction between range handling and compression also seems a little
ill-defined; as we have pre-compressed data, however, we can consistently
serve the exact same byte data for compressed files.