From ea1d5f36480c7f9ba9d15aebd94d3df7db95dd72 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 24 Feb 2012 18:42:33 -0500 Subject: [PATCH] Fix content-length: 0 #454 --- requests/models.py | 2 +- tests/test_requests.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/requests/models.py b/requests/models.py index a238214a..8dadf083 100644 --- a/requests/models.py +++ b/requests/models.py @@ -739,7 +739,7 @@ class Response(object): raise RuntimeError( 'The content for this response was already consumed') - self._content = bytes().join(self.iter_content()) or None + self._content = bytes().join(self.iter_content()) or bytes() # print repr(self._content) except AttributeError: self._content = None diff --git a/tests/test_requests.py b/tests/test_requests.py index 37212eb6..c06f88ad 100755 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -795,5 +795,11 @@ class RequestsTestSuite(TestSetup, unittest.TestCase): s.get(httpbin('redirect', '4')) + def test_empty_response(self): + r = requests.get(httpbin('status', '404')) + r.text + + + if __name__ == '__main__': unittest.main()