Skip to content

Incorrect handling of negative reading sizes in HTTPResponse.read() #128271

Closed as duplicate of#112064
@manushkin

Description

@manushkin

Bug report

Bug description:

connection = http.client.HTTPSConnection("some_address")
headers = {
    "Connection": "close",
}
connection.request("GET", "/some_path", headers=headers)
response = connection.getresponse()
assert response.chunked is True
# data = response.read(None)  # get correct answer
data = response.read(-1)  # get incorrect answer

Param value amt can be negative, e.x. -1.
In that case we read all data, with chunk separators, instead of correct reading.

P.S. example of using -1 here:
https://github.com/Textualize/rich/blob/master/rich/progress.py#L247

CPython versions tested on:

3.10, 3.11

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions