summaryrefslogtreecommitdiff
path: root/Lib/httplib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r--Lib/httplib.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 85e49abd28..2e749eabb6 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -626,7 +626,7 @@ class HTTPResponse:
while amt > 0:
chunk = self.fp.read(min(amt, MAXAMOUNT))
if not chunk:
- raise IncompleteRead(s)
+ raise IncompleteRead(''.join(s), amt)
s.append(chunk)
amt -= len(chunk)
return ''.join(s)
@@ -1161,9 +1161,18 @@ class UnimplementedFileMode(HTTPException):
pass
class IncompleteRead(HTTPException):
- def __init__(self, partial):
+ def __init__(self, partial, expected=None):
self.args = partial,
self.partial = partial
+ self.expected = expected
+ def __repr__(self):
+ if self.expected is not None:
+ e = ', %i more expected' % self.expected
+ else:
+ e = ''
+ return 'IncompleteRead(%i bytes read%s)' % (len(self.partial), e)
+ def __str__(self):
+ return repr(self)
class ImproperConnectionState(HTTPException):
pass