def generate_chunked():
resp = self.raw._original_response
fp = resp.fp
- if resp.chunk_left:
- yield fp.read(resp.chunk_left)
- fp.read(2) #throw away crlf
+ if resp.chunk_left is not None:
+ pending_bytes = resp.chunk_left
+ while pending_bytes:
+ chunk = fp.read(min(chunk_size, pending_bytes))
+ pending_bytes-=len(chunk)
+ yield chunk
+ fp.read(2) # throw away crlf
while 1:
- #XXX correct line size
+ #XXX correct line size? (httplib has 64kb, seems insane)
pending_bytes = fp.readline(40).strip()
pending_bytes = int(pending_bytes, 16)
if pending_bytes == 0:
yield chunk
fp.read(2) # throw away crlf
self._content_consumed = True
+ fp.close()
if getattr(getattr(self.raw, '_original_response', None), 'chunked', False):