mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #13222 -- Made HttpResponse iterable once
response.content can be accessed many times as desired, and always returns the same result. iter(response) works only once and consumes the iterator.
This commit is contained in:
@@ -596,7 +596,11 @@ class TransactionTestCase(SimpleTestCase):
|
||||
msg_prefix + "Couldn't retrieve content: Response code was %d"
|
||||
" (expected %d)" % (response.status_code, status_code))
|
||||
text = force_text(text, encoding=response._charset)
|
||||
content = b''.join(response).decode(response._charset)
|
||||
if response.streaming:
|
||||
content = b''.join(response.streaming_content)
|
||||
else:
|
||||
content = response.content
|
||||
content = content.decode(response._charset)
|
||||
# Avoid ResourceWarning about unclosed files.
|
||||
response.close()
|
||||
if html:
|
||||
|
||||
Reference in New Issue
Block a user