Issue #13713: fix a regression in HTTP chunked reading after 806cfe39f729

(originally issue #13464: Add a readinto() method to http.client.HTTPResponse)
This commit is contained in:
Antoine Pitrou 2012-01-04 18:57:22 +01:00
parent d710d147f6
commit f7e7818e24
2 changed files with 51 additions and 17 deletions

View file

@ -603,12 +603,12 @@ class HTTPResponse(io.RawIOBase):
if len(mvb) < chunk_left:
n = self._safe_readinto(mvb)
self.chunk_left = chunk_left - n
return n
return total_bytes + n
elif len(mvb) == chunk_left:
n = self._safe_readinto(mvb)
self._safe_read(2) # toss the CRLF at the end of the chunk
self.chunk_left = None
return n
return total_bytes + n
else:
temp_mvb = mvb[0:chunk_left]
n = self._safe_readinto(temp_mvb)