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

read1 and readline of http.client.HTTPResponse do not raise IncompleteRead #115997

Open
illia-v opened this issue Feb 27, 2024 · 1 comment
Open
Labels
type-bug An unexpected behavior, bug, or error

Comments

@illia-v
Copy link
Contributor

illia-v commented Feb 27, 2024

Bug report

Bug description:

Unlike http.client.HTTPResponse.read, read1 and readline do not raise IncompleteRead when the content length is know and a connection is closed before everything has been read.

FYI, these two methods have had a common issue in the past #113199.

CPython versions tested on:

3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch

Operating systems tested on:

Linux, macOS, Windows

Linked PRs

@illia-v illia-v added the type-bug An unexpected behavior, bug, or error label Feb 27, 2024
illia-v added a commit to illia-v/cpython that referenced this issue Feb 27, 2024
illia-v added a commit to illia-v/cpython that referenced this issue Feb 27, 2024
illia-v added a commit to illia-v/cpython that referenced this issue Mar 27, 2024
illia-v added a commit to illia-v/cpython that referenced this issue Jun 6, 2024
@serhiy-storchaka
Copy link
Member

I am not sure that they should raise IncompleteRead.

AFAIK, only read() without argument raises IncompleteRead, because it needs to read the whole content. read1() and readline() without argument have different semantic, they do not read to the end of the stream. readline() reads to the first end of line, and read1() returns the amount of data depending on buffering. Raising IncompleteRead with second argument equal to self.length would be incorrect, because we cannot guarantee that read1() and readline() would return the specified number of bytes if the connection was not closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants