summaryrefslogtreecommitdiff
path: root/Lib/httplib.py
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2007-10-18 03:16:03 +0000
committerFacundo Batista <facundobatista@gmail.com>2007-10-18 03:16:03 +0000
commit7066590736bb61b5f67ade490aeee327af4bc6e2 (patch)
tree4a98d6267b59eae611c7f0f116ea05b6fe368fc6 /Lib/httplib.py
parenta1e42e11d51237a949ad2568f8a097d4b442fdec (diff)
downloadcpython-git-7066590736bb61b5f67ade490aeee327af4bc6e2.tar.gz
Issue #1580738. When HTTPConnection reads the whole stream with read(),
it closes itself. When the stream is read in several calls to read(n), it should behave in the same way if HTTPConnection knows where the end of the stream is (through self.length). Added a test case for this behaviour.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r--Lib/httplib.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 8dbe8a07e4..dca9eca777 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -530,7 +530,8 @@ class HTTPResponse:
s = self.fp.read(amt)
if self.length is not None:
self.length -= len(s)
-
+ if not self.length:
+ self.close()
return s
def _read_chunked(self, amt):