summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-10-23 00:08:56 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-10-23 00:11:17 +0200
commitea57112d531dfc6d2be50f47ee89f3a06f8ff1a8 (patch)
treec45306780c2f7860e7c9b446850663f8cf50d40c
parent11a4b6d9239471b3675900f3019f698a98acf590 (diff)
Reverted 6a64822bf4632707212314a25a843c862bdb3874.
This commit caused every test that does two or more assertContains to fail, because of #6527. It also made HttpResponse non-pickleable. Refs #13222.
-rw-r--r--django/http/response.py4
-rw-r--r--tests/regressiontests/httpwrappers/tests.py7
2 files changed, 2 insertions, 9 deletions
diff --git a/django/http/response.py b/django/http/response.py
index 49145cd822..4a5c479419 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -260,9 +260,9 @@ class HttpResponse(HttpResponseBase):
else:
self._container = [value]
self._base_content_is_iter = False
- self._iterator = iter(self._container)
def __iter__(self):
+ self._iterator = iter(self._container)
return self
def __next__(self):
@@ -284,7 +284,7 @@ class HttpResponse(HttpResponseBase):
def tell(self):
if self._base_content_is_iter:
raise Exception("This %s instance cannot tell its position" % self.__class__.__name__)
- return len(self.content)
+ return sum([len(chunk) for chunk in self])
class StreamingHttpResponse(HttpResponseBase):
diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
index 803cbf029f..bfb4ae1fd5 100644
--- a/tests/regressiontests/httpwrappers/tests.py
+++ b/tests/regressiontests/httpwrappers/tests.py
@@ -330,13 +330,6 @@ class HttpResponseTests(unittest.TestCase):
self.assertRaises(UnicodeEncodeError,
getattr, r, 'content')
- def test_iterator_isnt_rewound(self):
- # Regression test for #13222
- r = HttpResponse('abc')
- i = iter(r)
- self.assertEqual(list(i), [b'abc'])
- self.assertEqual(list(i), [])
-
def test_file_interface(self):
r = HttpResponse()
r.write(b"hello")