Skip to content

Commit

Permalink
chunk_size iter_lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Reitz committed Mar 9, 2012
1 parent c7f165a commit 4aad695
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ History

* Generate chunked ValueError fix
* Proxy configuration by environment variables
* Simplification of iter_lines.
* New `trust_env` configuration for disabling system/environment hints.



0.10.7 (2012-03-07)
Expand Down
6 changes: 4 additions & 2 deletions requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,15 +704,17 @@ def generate_chunked():

return gen

def iter_lines(self, decode_unicode=None):
def iter_lines(self, chunk_size=10 * 1024, decode_unicode=None):
"""Iterates over the response data, one line at a time. This
avoids reading the content at once into memory for large
responses.
"""

pending = None

for chunk in self.iter_content(chunk_size=10 * 1024, decode_unicode=decode_unicode):
for chunk in self.iter_content(
chunk_size=chunk_size,
decode_unicode=decode_unicode):

if pending is not None:
chunk = pending + chunk
Expand Down

0 comments on commit 4aad695

Please sign in to comment.