From 0dbda6665d65b186107e01b03ae901684a7f5ecb Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 21 Jan 2012 22:59:57 -0500 Subject: [PATCH] cleanup --- requests/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index 0d08bea..c4a3fae 100644 --- a/requests/models.py +++ b/requests/models.py @@ -677,16 +677,21 @@ class Response(object): avoids reading the content at once into memory for large responses. """ - #XXX: why rstrip by default + #TODO: why rstrip by default pending = None + for chunk in self.iter_content(chunk_size, decode_unicode=decode_unicode): + if pending is not None: chunk = pending + chunk lines = chunk.splitlines(True) + for line in lines[:-1]: yield line.rstrip() + # Save the last part of the chunk for next iteration, to keep full line together # lines may be empty for the last chunk of a chunked response + if lines: pending = lines[-1] #if pending is a complete line, give it baack -- 2.34.1