mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
+5
-1
@@ -496,7 +496,11 @@ class Response(object):
|
||||
'already consumed')
|
||||
|
||||
# Read the contents.
|
||||
self._content = self.raw.read()
|
||||
try:
|
||||
self._content = self.raw.read()
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
|
||||
# Decode GZip'd content.
|
||||
if 'gzip' in self.headers.get('content-encoding', ''):
|
||||
|
||||
@@ -529,6 +529,11 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
assert params3['b'] in r3.content
|
||||
assert params3['c'] in r3.content
|
||||
|
||||
def test_invalid_content(self):
|
||||
|
||||
r = requests.get('http://somedomainthatclearlydoesntexistg.com')
|
||||
assert r.content == None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user