diff options
Diffstat (limited to 'django/http/__init__.py')
| -rw-r--r-- | django/http/__init__.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index a8c8afe433..ca3b5eab24 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -222,12 +222,6 @@ class HttpResponse(object): content = ''.join(self._container) if isinstance(content, unicode): content = content.encode(self._charset) - - # If self._container was an iterator, we have just exhausted it, so we - # need to save the results for anything else that needs access - if not self._is_string: - self._container = [content] - self._is_string = True return content def _set_content(self, value): @@ -237,10 +231,14 @@ class HttpResponse(object): content = property(_get_content, _set_content) def __iter__(self): - for chunk in self._container: - if isinstance(chunk, unicode): - chunk = chunk.encode(self._charset) - yield chunk + self._iterator = self._container.__iter__() + return self + + def next(self): + chunk = self._iterator.next() + if isinstance(chunk, unicode): + chunk = chunk.encode(self._charset) + return chunk def close(self): if hasattr(self._container, 'close'): |
