Skip to content
Myr

close the chunked fd at the end and honor content chunksizes for a potential first chunk

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ronny Pfannschmidt · committed by Ronny Pfannschmidt · parent 1c8a141 · Browse files · 1 file+9 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−4 removed

  • other:+9 added−4 removed

1 file+9 added−4 removed

modified:requests/models.py+9 added-4 removed
613 unmodified lines
614 615 def generate_chunked():616 resp = self.raw._original_response617 fp = resp.fp618 if resp.chunk_left:619 yield fp.read(resp.chunk_left)620 fp.read(2) #throw away crlf618 if resp.chunk_left is not None:619 pending_bytes = resp.chunk_left620 while pending_bytes:621 chunk = fp.read(min(chunk_size, pending_bytes))622 pending_bytes-=len(chunk)623 yield chunk624 fp.read(2) # throw away crlf625 while 1:622 #XXX correct line size626 #XXX correct line size? (httplib has 64kb, seems insane)627 pending_bytes = fp.readline(40).strip()628 pending_bytes = int(pending_bytes, 16)629 if pending_bytes == 0:630 break
2 unmodified lines
633 pending_bytes-=len(chunk)634 yield chunk635 fp.read(2) # throw away crlf636 self._content_consumed = True637 fp.close()638639640 if getattr(getattr(self.raw, '_original_response', None), 'chunked', False):641 gen = generate_chunked()
102 unmodified lines