Skip to content

Make HTTPResponse.read1 close response when all data is read#3235

Merged
illia-v merged 11 commits intourllib3:mainfrom
illia-v:read1-close
Jan 22, 2024
Merged

Make HTTPResponse.read1 close response when all data is read#3235
illia-v merged 11 commits intourllib3:mainfrom
illia-v:read1-close

Conversation

@illia-v
Copy link
Member

@illia-v illia-v commented Dec 15, 2023

In #3216, we discovered that CPython's http.client.HTTPResponse.read1 never closes the response after all data has been read and content length was known.

This PR adds a fix for the issue to _raw_read near a similar old fix that closes a response under a different condition.
I'll create a PR to fix this in CPython too most likely.

pquentin
pquentin previously approved these changes Dec 19, 2023
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! Congrats in getting your CPython fix in.

@sethmlarson sethmlarson self-requested a review December 19, 2023 19:24
Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying the behavior of read1() to me! I only had one review comment then this LGTM:

@illia-v illia-v requested a review from sethmlarson December 19, 2023 20:39
@illia-v
Copy link
Member Author

illia-v commented Jan 7, 2024

@sethmlarson @pquentin can we merge this?

sethmlarson
sethmlarson previously approved these changes Jan 22, 2024
Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me, I'm sad we're having to get so specific for http.client but since we're working around a bug in that implementation it makes sense. Thanks Illia!

@illia-v illia-v requested a review from sethmlarson January 22, 2024 18:28
@illia-v illia-v merged commit 6b2b377 into urllib3:main Jan 22, 2024
@illia-v illia-v deleted the read1-close branch January 22, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog Pull requests that don't require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants