-
-
Notifications
You must be signed in to change notification settings - Fork 32k
http.client.HTTPResponse.read1
does not close response after reading all data
#113199
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
Comments
Is it a bug? The next reading operation will return an empty bytes and close the connection. So it may be just an optimization. The |
This was probably an oversight and I think this should be fixed. |
Closing won't happen when the content length is known. Lines 661 to 665 in 21d5299
After it has read all data, any subsequent call will reset |
Nice necro. Yes, probably an oversight. The original impetus was to read from streams that didn't close. |
… reading all data (GH-113200)
… after reading all data (pythonGH-113200) (cherry picked from commit 41336a7) Co-authored-by: Illia Volochii <[email protected]>
… after reading all data (pythonGH-113200) (cherry picked from commit 41336a7) Co-authored-by: Illia Volochii <[email protected]>
Thank you for your contribution @illia-v. |
…O after reading all data (GH-113200) (GH-113260) (cherry picked from commit 41336a7) Co-authored-by: Illia Volochii <[email protected]>
…O after reading all data (GH-113200) (GH-113259) (cherry picked from commit 41336a7) Co-authored-by: Illia Volochii <[email protected]>
Thanks everyone! Can this be closed now? |
@serhiy-storchaka @pitrou @kristjanvalur @pquentin thank you for your attention! |
… after reading all data (pythonGH-113200)
… after reading all data (pythonGH-113200)
… after reading all data (pythonGH-113200)
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
While trying to use
read1
in urllib3, we discovered thatread1
unlikeread
never closes the response after reading all data when the content length is known (urllib3/urllib3#3235).This runs successfully:
This fails:
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
read1
andreadline
ofHTTPResponse
close IO after reading all data #113200The text was updated successfully, but these errors were encountered: