Skip to content

Add parameter to iter_content to disable content decoding #958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def ok(self):
return False
return True

def iter_content(self, chunk_size=1, decode_unicode=False):
def iter_content(self, chunk_size=1, decode_unicode=False, decode_content=True):
"""Iterates over the response data. This avoids reading the content
at once into memory for large responses. The chunk size is the number
of bytes it should read into memory. This is not necessarily the
Expand All @@ -760,7 +760,8 @@ def generate():
yield chunk
self._content_consumed = True

gen = stream_untransfer(generate(), self)
if decode_content:
gen = stream_untransfer(generate(), self)

if decode_unicode:
gen = stream_decode_response_unicode(gen, self)
Expand Down