Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

byte range issue #47

Closed
iowelinux opened this issue Feb 8, 2016 · 3 comments
Closed

byte range issue #47

iowelinux opened this issue Feb 8, 2016 · 3 comments

Comments

@iowelinux
Copy link

Hi,

Seems like an issue with byte range requests.

E.g.
File size: 210720491 bytes

When I send a request with the header "Range: bytes=95644624-" fasthttp handles it correctly.
However if we'll modify the header to "Range: bytes=95644624-210720491" (from 95644624 to the last byte of the file) it drops to 416 http error because it can't handle the byte range.

cannot parse byte range "bytes=97851544-210720491" for path="/some_file.dat": invalid byte range

For instance I've just checked Nginx and it handles the same query correctly.

@valyala
Copy link
Owner

valyala commented Feb 8, 2016

Thanks for the bug report, @iowelinux .

According to byte range RFC:

The last-byte-pos value gives the byte-offset of the last byte in the range; that is, the byte positions specified are inclusive. Byte offsets start at zero.

This means that the last byte of your file must be 210720490, not 210720491. It looks like nginx has a workaround for this one-off error, since the error is quite widespread. I'm investigating this further and will add the corresponding workaround if required.

@valyala
Copy link
Owner

valyala commented Feb 8, 2016

Nginx implements new byte range RFC, which allows out-of-range end position. See the corresponding commit and the corresponding RFC:

If the last-byte-pos value is absent, or if the value is greater than or equal to the current length of the entity-body, last-byte-pos is taken to be equal to one less than the current length of the entity- body in bytes.

I'll implement the same in fasthttp

@valyala
Copy link
Owner

valyala commented Feb 8, 2016

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants