Skip to content

BaseRequest.http_range returns the wrong slice when "start" is missing #2805

Closed
@Fahrradkette

Description

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 :)

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions