eikek/sharry

"Range: bytes=0-1023" wrong response

branek opened this issue · 1 comments

branek commented

Sharry version: Sharry 1.12.1 (#d6d74cc9)

If client requests only range of bytes from Sharry server, it will get wrong response.

By definition, Content-range: header is defined as (Content-Range):

Content-Range: <unit> <range-start>-<range-end>/<size>
Content-Range: <unit> <range-start>-<range-end>/*
Content-Range: <unit> */<size>

And directives are:
Directives
<unit>
The unit in which ranges are specified. This is usually bytes.

<range-start>
An integer in the given unit indicating the start position (zero-indexed & inclusive) of the request range.

<range-end>
An integer in the given unit indicating the end position (zero-indexed & inclusive) of the requested range.

<size>
The total length of the document (or '*' if unknown).

For the request:

curl http://server/file.bin -i -H "Range: bytes=0-1023"

Returned Content-Length: should be as:

Content-Length: 1024
Content-Range: bytes 0-1023/347504
Content-Type: application/octet-stream

but mentioned above Sharry version returns:

Content-Length: 1023
Content-Range: bytes 0-1023/347504

and body is also missing one byte (last one). Proper fix would be to return zero-indexed & inclusive range for start and end indexes.

eikek commented

Thank you for the thorough report! Unbelievable that this got not noticed before :) Probably clients are lenient to these things (fortunately).