diff options
author | Illia Volochii <illia.volochii@gmail.com> | 2023-12-18 22:17:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 22:17:16 +0200 |
commit | 41336a72b90634d5ac74a57b6826e4dd6fe78eac (patch) | |
tree | 363b462522a7bd0422f1c1ad14f399b9550f7f48 /Lib/http/client.py | |
parent | 2feec0fc7fd0b9caae7ab2e26e69311d3ed93e77 (diff) | |
download | cpython-41336a72b90634d5ac74a57b6826e4dd6fe78eac.tar.gz cpython-41336a72b90634d5ac74a57b6826e4dd6fe78eac.zip |
gh-113199: Make read1() and readline() of HTTPResponse close IO after reading all data (GH-113200)
Diffstat (limited to 'Lib/http/client.py')
-rw-r--r-- | Lib/http/client.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py index 7bb5d824bb6..5eebfccafbc 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -665,6 +665,8 @@ class HTTPResponse(io.BufferedIOBase): self._close_conn() elif self.length is not None: self.length -= len(result) + if not self.length: + self._close_conn() return result def peek(self, n=-1): @@ -689,6 +691,8 @@ class HTTPResponse(io.BufferedIOBase): self._close_conn() elif self.length is not None: self.length -= len(result) + if not self.length: + self._close_conn() return result def _read1_chunked(self, n): |