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

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

Open
manushkin opened this issue Dec 26, 2024 · 0 comments
Open

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

manushkin opened this issue Dec 26, 2024 · 0 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@manushkin
Copy link

manushkin commented Dec 26, 2024

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

@manushkin manushkin added the type-bug An unexpected behavior, bug, or error label Dec 26, 2024
@picnixz picnixz changed the title Incorrect http read_chunked for amt with negative value Incorrect handling of negative reading sizes in HTTPResponse.read() Dec 26, 2024
@picnixz picnixz added the stdlib Python modules in the Lib dir label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants