Ticket #13222: httpresponse2.diff
File httpresponse2.diff, 1.7 KB (added by , 14 years ago) |
---|
-
django/http/__init__.py
600 600 content = property(_get_content, _set_content) 601 601 602 602 def __iter__(self): 603 self._iterator = iter(self._container) 604 return self 603 for chunk in self._container: 604 if isinstance(chunk, unicode): 605 chunk = chunk.encode(self._charset) 606 yield str(chunk) 605 607 606 def next(self):607 chunk = self._iterator.next()608 if isinstance(chunk, unicode):609 chunk = chunk.encode(self._charset)610 return str(chunk)611 612 608 def close(self): 613 609 if hasattr(self._container, 'close'): 614 610 self._container.close() -
tests/regressiontests/httpwrappers/tests.py
243 243 self.assertRaises(BadHeaderError, r.__setitem__, 'test\rstr', 'test') 244 244 self.assertRaises(BadHeaderError, r.__setitem__, 'test\nstr', 'test') 245 245 246 def test_iteration(self): 247 r = HttpResponse("foobar") 248 it = iter(r) 249 self.assertEqual(list(it), ["foobar"]) 250 self.assertEqual(list(it), []) 251 252 r = HttpResponse(["foo", "bar", "spam", "eggs"]) 253 it1 = iter(r) 254 it2 = iter(r) 255 self.assertEqual(zip(it1, it2), [("foo", "foo"), ("bar", "bar"), 256 ("spam", "spam"), ("eggs", "eggs")]) 257 246 258 class CookieTests(unittest.TestCase): 247 259 def test_encode(self): 248 260 """