Merge pull request #542 from newmaniese/develop

Attempting to address issue #377 by making content on the response model a little smarter
This commit is contained in:
Kenneth Reitz
2012-04-08 20:13:38 -07:00
3 changed files with 10 additions and 4 deletions
+2 -1
View File
@@ -92,4 +92,5 @@ Patches and Suggestions
- Jonathan Drosdeck
- Jiri Machalek
- Steve Pulec
- Michael Kelly
- Michael Kelly
- Michael Newman <newmaniese@gmail.com>
+3 -3
View File
@@ -623,7 +623,7 @@ class Response(object):
def __init__(self):
self._content = None
self._content = False
self._content_consumed = False
#: Integer Code of responded HTTP Status.
@@ -736,7 +736,7 @@ class Response(object):
def content(self):
"""Content of the response, in bytes."""
if self._content is None:
if self._content is False:
# Read the contents.
try:
if self._content_consumed:
@@ -751,7 +751,7 @@ class Response(object):
except AttributeError:
self._content = None
self._content_consumed = True
self._content_consumed = True
return self._content
def _detected_encoding(self):
+5
View File
@@ -800,5 +800,10 @@ class RequestsTestSuite(TestSetup, unittest.TestCase):
r = requests.get(httpbin('status', '404'))
r.text
def test_no_content(self):
r = requests.get(httpbin('status', "0"), config={"safe_mode":True})
r.content
r.content
if __name__ == '__main__':
unittest.main()