diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-15 18:11:54 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-15 18:11:54 (GMT) |
commit | 084daa2f7492ae809b5ce09d2cdbad6ed5a71848 (patch) | |
tree | 9677bfc6f88f04a9b82a89d9698f5e6e65c8193f /Lib/http | |
parent | e0035a212ba6acbff6b1262dd6930a3a7ec1f204 (diff) | |
download | cpython-084daa2f7492ae809b5ce09d2cdbad6ed5a71848.zip cpython-084daa2f7492ae809b5ce09d2cdbad6ed5a71848.tar.gz cpython-084daa2f7492ae809b5ce09d2cdbad6ed5a71848.tar.bz2 |
Issue #16298: In HTTPResponse.read(), close the socket when there is no Content-Length and the incoming stream is finished.
Patch by Eran Rundstein.
Diffstat (limited to 'Lib/http')
-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 97a7155..4d93b93 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -511,6 +511,10 @@ class HTTPResponse(io.RawIOBase): self.length -= len(s) if not self.length: self.close() + else: + if not s: + self.close() + return s def _read_chunked(self, amt): |