Skip to content
Myr

Merge branch 'develop' of https://github.com/gazpachoking/requests into develop

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 281e059, 5174ab4 · Browse files · 1 file+13 added−22 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+13 added−22 removed

  • other:+13 added−22 removed

1 file+13 added−22 removed

modified:requests/models.py+13 added-22 removed
7 unmodified lines
8"""910import os11import urllib12import zlib1213from urlparse import urlparse, urlunparse, urljoin, urlsplit14from datetime import datetime15
612 unmodified lines
628629 return gen630631633 def iter_lines(self, newlines=None, decode_unicode=None):632 def iter_lines(self, chunk_size=10 * 1024, decode_unicode=None):633 """Iterates over the response data, one line at a time. This634 avoids reading the content at once into memory for large635 responses.637638 :param newlines: a collection of bytes to seperate lines with.636 """637641 if newlines is None:642 newlines = ('\r', '\n', '\r\n')638 pending = None639 for chunk in self.iter_content(chunk_size, decode_unicode=decode_unicode):640 if pending is not None:641 chunk = pending + chunk642 lines = chunk.splitlines(True)643 for line in lines[:-1]:644 yield line.rstrip()645 # Save the last part of the chunk for next iteration, to keep full line together646 pending = lines[-1]647644 chunk = []648 # Yield the last line649 if pending is not None:650 yield pending.rstrip()651646 for c in self.iter_content(1, decode_unicode=decode_unicode):647 if not c:648 break652650 if c in newlines:651 yield ''.join(chunk)652 chunk = []653 else:654 chunk.append(c)655656 # Yield the remainder, in case the response657 # did not terminate with a newline658 if chunk:659 yield ''.join(chunk)660661653 @property654 def content(self):655 """Content of the response, in bytes or unicode656 (if available).
52 unmodified lines