mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
remote read/close methods from response
This commit is contained in:
+1
-10
@@ -186,9 +186,7 @@ class Request(object):
|
||||
|
||||
try:
|
||||
response.headers = CaseInsensitiveDict(getattr(resp.info(), 'dict', None))
|
||||
response.read = resp.read
|
||||
response.fo = resp
|
||||
response._close = resp.close
|
||||
|
||||
if self.cookiejar:
|
||||
|
||||
@@ -443,7 +441,7 @@ class Response(object):
|
||||
return self._content
|
||||
|
||||
# Read the contents.
|
||||
self._content = self.read()
|
||||
self._content = self.fo.read()
|
||||
|
||||
# Decode GZip'd content.
|
||||
if 'gzip' in self.headers.get('content-encoding', ''):
|
||||
@@ -462,19 +460,12 @@ class Response(object):
|
||||
raise AttributeError
|
||||
|
||||
|
||||
|
||||
def raise_for_status(self):
|
||||
"""Raises stored :class:`HTTPError` or :class:`URLError`, if one occured."""
|
||||
if self.error:
|
||||
raise self.error
|
||||
|
||||
|
||||
def close(self):
|
||||
if self.fo.fp is not None and hasattr(self.fo.fp, '_sock'):
|
||||
self.fo.fp._sock.recv = None
|
||||
self._close()
|
||||
|
||||
|
||||
|
||||
class AuthManager(object):
|
||||
"""Requests Authentication Manager."""
|
||||
|
||||
Reference in New Issue
Block a user