Skip to content

gh-113199: Make read1 and readline of HTTPResponse close IO after reading all data #113200

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

Merged
merged 4 commits into from
Dec 18, 2023

Conversation

illia-v
Copy link
Contributor

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

The added code is very similar to what already exists in read:

cpython/Lib/http/client.py

Lines 484 to 487 in 7322221

elif self.length is not None:
self.length -= len(s)
if not self.length:
self._close_conn()

@serhiy-storchaka
Copy link
Member

There is a similar case in readline(). Do you mind to add autodisconnect there too?

@illia-v illia-v changed the title gh-113199: Make HTTPResponse.read1 close IO after reading all data gh-113199: Make read1 and readline of HTTPResponse close IO after reading all data Dec 17, 2023
@illia-v
Copy link
Contributor Author

illia-v commented Dec 17, 2023

There is a similar case in readline(). Do you mind to add autodisconnect there too?

Added, thanks for the suggestion!

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@kristjanvalur
Copy link
Contributor

Yes, this is how it should be, I guess :)

@serhiy-storchaka serhiy-storchaka added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Dec 18, 2023
@serhiy-storchaka serhiy-storchaka merged commit 41336a7 into python:main Dec 18, 2023
@miss-islington-app
Copy link

Thanks @illia-v for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 18, 2023
… after reading all data (pythonGH-113200)

(cherry picked from commit 41336a7)

Co-authored-by: Illia Volochii <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Dec 18, 2023

GH-113259 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Dec 18, 2023
@bedevere-app
Copy link

bedevere-app bot commented Dec 18, 2023

GH-113260 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 18, 2023
… after reading all data (pythonGH-113200)

(cherry picked from commit 41336a7)

Co-authored-by: Illia Volochii <[email protected]>
@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Dec 18, 2023
serhiy-storchaka pushed a commit that referenced this pull request Dec 18, 2023
…O after reading all data (GH-113200) (GH-113260)

(cherry picked from commit 41336a7)

Co-authored-by: Illia Volochii <[email protected]>
serhiy-storchaka pushed a commit that referenced this pull request Dec 18, 2023
…O after reading all data (GH-113200) (GH-113259)

(cherry picked from commit 41336a7)

Co-authored-by: Illia Volochii <[email protected]>
ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull request Dec 26, 2023
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants