Skip to content

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

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

Closed
manushkin opened this issue Dec 26, 2024 · 2 comments
Closed

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

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

Comments

@manushkin
Copy link
Contributor

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
@vadmium
Copy link
Member

vadmium commented Jan 3, 2025

Duplicate of #112064

@vadmium vadmium marked this as a duplicate of #112064 Jan 3, 2025
@Eclips4
Copy link
Member

Eclips4 commented Jan 28, 2025

(Closing as duplicate)

@Eclips4 Eclips4 closed this as completed Jan 28, 2025
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

4 participants