1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Simplified iteration in HTTP response objects.

Fixed #20187 -- Allowed repeated iteration of HttpResponse.

All this became possible when support for old-style streaming responses was
finally removed.
This commit is contained in:
Aymeric Augustin
2013-11-23 17:03:43 +01:00
parent 1124e16340
commit a480f8320a
2 changed files with 14 additions and 16 deletions

View File

@@ -356,10 +356,10 @@ class HttpResponseTests(unittest.TestCase):
r = HttpResponse(iter(['hello', 'world']))
self.assertEqual(r.content, r.content)
self.assertEqual(r.content, b'helloworld')
# accessing the iterator works (once) after accessing .content
# __iter__ can safely be called multiple times (#20187).
self.assertEqual(b''.join(r), b'helloworld')
self.assertEqual(b''.join(r), b'')
# accessing .content still works
self.assertEqual(b''.join(r), b'helloworld')
# Accessing .content still works.
self.assertEqual(r.content, b'helloworld')
# Accessing .content also works if the response was iterated first.