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()