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

This commit is contained in:
Illia Volochii 2023-12-18 22:17:16 +02:00 committed by GitHub
parent 2feec0fc7f
commit 41336a72b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 2 deletions

View file

@ -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):