Index: httplib.py =================================================================== --- httplib.py (revision 59254) +++ httplib.py (working copy) @@ -547,7 +547,11 @@ i = line.find(';') if i >= 0: line = line[:i] # strip chunk-extensions - chunk_left = int(line, 16) + try: + chunk_left = int(line, 16) + except ValueError: + # A workaround for invalid chunk-size. [issue #1205] + chunk_left = 0 if chunk_left == 0: break if amt is None: @@ -573,7 +577,7 @@ ### note: we shouldn't have any trailers! while True: line = self.fp.readline() - if line == '\r\n': + if line == '\r\n' or not line: break # we read everything; close the "file"