summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2004-11-07 16:13:49 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2004-11-07 16:13:49 (GMT)
commitdef9d2a17c6f34750f321e88286a08731fdb8b94 (patch)
treeec4e53f14010b83dbb58a8c2a6cc5a27ce6e397a
parentf164322fe8115abe0d20f087391e67843255f578 (diff)
downloadcpython-def9d2a17c6f34750f321e88286a08731fdb8b94.zip
cpython-def9d2a17c6f34750f321e88286a08731fdb8b94.tar.gz
cpython-def9d2a17c6f34750f321e88286a08731fdb8b94.tar.bz2
Fix for SF bug 988120 via patch 1061941.
If read() returned less than the number of bytes request, the full amount was subtracted from length instead of the actually read amount.
-rw-r--r--Lib/httplib.py6
-rw-r--r--Misc/ACKS1
2 files changed, 5 insertions, 2 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 72e8a72..01fc1ee 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -457,10 +457,11 @@ class HTTPResponse:
if amt is None:
# unbounded read
- if self.will_close:
+ if self.length is None:
s = self.fp.read()
else:
s = self._safe_read(self.length)
+ self.length = 0
self.close() # we read everything
return s
@@ -468,12 +469,13 @@ class HTTPResponse:
if amt > self.length:
# clip the read to the "end of response"
amt = self.length
- self.length -= amt
# we do not use _safe_read() here because this may be a .will_close
# connection, and the user is reading more bytes than will be provided
# (for example, reading in 1k chunks)
s = self.fp.read(amt)
+ if self.length is not None:
+ self.length -= len(s)
return s
diff --git a/Misc/ACKS b/Misc/ACKS
index 58dd0ad..b2528f7 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -302,6 +302,7 @@ Jiba
Orjan Johansen
Simon Johnston
Richard Jones
+Irmen de Jong
Lucas de Jonge
Jens B. Jorgensen
John Jorgensen