-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
BaseRequest.http_range returns the wrong slice when "start" is missing #2805
Comments
Would you make a pull request? |
While what @Fahrradkette reported would be a nice and clean pull request to fix (and if he doesn't have the time/need I can take a stab at that) the problem is deeper than what is described in this ticket. According to the RFC https://tools.ietf.org/html/rfc7233 section 2.1 the following are all valid range requests (when concerning bytes): bytes=0-499 The above can all be easily supported and are as you expect. However the following are also valid: bytes=500-600,601-999 Where the response would be a multipart with those byte ranges. However currently in the above mentioned function only a single slice can be returned :) What are your ideas on supporting the entire Range grammar which would likely be much more complex versus just fixing the first part of it. My opinion is to either support all of Range or none. |
I doubt if multi-range requests are wide spread. Lets keep the single range for simplicity. |
In that case if @Fahrradkette wants to create a pull request they can, otherwise I can. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Long story short
When streaming range based requests from file, the method http_range comes quite handy, unfortunately negative indexes don't work as expected.
The offending line 442 is in web_request.py it should be "start = -end" instead of "end = -end"
Other valid ranges are described in https://tools.ietf.org/html/rfc7233#section-2.1
I don't know if it's allowed to just return a 416 on the more exotic ones though:)
Expected behaviour
[Request Header]
Range: bytes=-5678
[BaseRequest.http_range]
slice(start=-5678, stop=None, step=1)
Actual behaviour
[Request Header]
Range: bytes=-5678
[BaseRequest.http_range]
slice(start=None, stop=-5678, step=1)
Steps to reproduce
run an aiohttp server and request a resource using the range header.
(do I have to post the whole setup, code included?)
Your environment
Running aiohttp 1.2.0 on debian 9 (stretch) ... I know, I know :)
The text was updated successfully, but these errors were encountered: