diff --git a/django/http/response.py b/django/http/response.py
index 4a5c479..49145cd 100644
a
|
b
|
class HttpResponse(HttpResponseBase):
|
260 | 260 | else: |
261 | 261 | self._container = [value] |
262 | 262 | self._base_content_is_iter = False |
| 263 | self._iterator = iter(self._container) |
263 | 264 | |
264 | 265 | def __iter__(self): |
265 | | self._iterator = iter(self._container) |
266 | 266 | return self |
267 | 267 | |
268 | 268 | def __next__(self): |
… |
… |
class HttpResponse(HttpResponseBase):
|
284 | 284 | def tell(self): |
285 | 285 | if self._base_content_is_iter: |
286 | 286 | raise Exception("This %s instance cannot tell its position" % self.__class__.__name__) |
287 | | return sum([len(chunk) for chunk in self]) |
| 287 | return len(self.content) |
288 | 288 | |
289 | 289 | |
290 | 290 | class StreamingHttpResponse(HttpResponseBase): |
diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
index bfb4ae1..803cbf0 100644
a
|
b
|
class HttpResponseTests(unittest.TestCase):
|
330 | 330 | self.assertRaises(UnicodeEncodeError, |
331 | 331 | getattr, r, 'content') |
332 | 332 | |
| 333 | def test_iterator_isnt_rewound(self): |
| 334 | # Regression test for #13222 |
| 335 | r = HttpResponse('abc') |
| 336 | i = iter(r) |
| 337 | self.assertEqual(list(i), [b'abc']) |
| 338 | self.assertEqual(list(i), []) |
| 339 | |
333 | 340 | def test_file_interface(self): |
334 | 341 | r = HttpResponse() |
335 | 342 | r.write(b"hello") |