"""
self.poolmanager.clear()
- def send(self, request, prefetch=True, timeout=None, verify=True, cert=None, proxies=None):
+ def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
"""Sends PreparedRequest object. Returns Response object."""
conn = self.get_connection(request.url, proxies)
r = self.build_response(request, resp)
- if prefetch:
+ if not stream:
r.content
return r
:param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
:param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
:param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.
- :param prefetch: (optional) if ``True``, the response content will be immediately downloaded.
+ :param stream: (optional) if ``False``, the response content will be immediately downloaded.
:param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.
"""
self.headers = CaseInsensitiveDict()
#: File-like object representation of response (for advanced usage).
- #: Requires that ``prefetch=False` on the request.
+ #: Requires that ``stream=True` on the request.
# This requirement does not apply for use internally to Requests.
self.raw = None
#: up here. The list is sorted from the oldest to the most recent request.
self.history = []
- #: The :class:`Request <Request>` that created the Response.
- # self.request = None
self.reason = None
# Fallback to auto-detected encoding.
if self.encoding is None:
- if chardet is not None:
- encoding = chardet.detect(self.content)['encoding']
+ encoding = self.apparent_encoding
# Decode unicode from given encoding.
try:
class SessionRedirectMixin(object):
- def resolve_redirects(self, resp, req, prefetch=True, timeout=None, verify=True, cert=None):
+ def resolve_redirects(self, resp, req, stream=False, timeout=None, verify=True, cert=None):
"""Receives a Response. Returns a generator of Responses."""
i = 0
auth=req.auth,
cookies=req.cookies,
allow_redirects=False,
- prefetch=prefetch,
+ stream=stream,
timeout=timeout,
verify=verify,
cert=cert
#: representing multivalued query parameters.
self.params = {}
- #: Prefetch response content.
- self.prefetch = True
+ #: Stream response content.
+ self.stream = False
#: SSL Verification.
self.verify = True
allow_redirects=True,
proxies=None,
hooks=None,
- prefetch=None,
+ stream=None,
verify=None,
cert=None):
auth = merge_kwargs(auth, self.auth)
proxies = merge_kwargs(proxies, self.proxies)
hooks = merge_kwargs(hooks, self.hooks)
- prefetch = merge_kwargs(prefetch, self.prefetch)
+ stream = merge_kwargs(stream, self.stream)
verify = merge_kwargs(verify, self.verify)
cert = merge_kwargs(cert, self.cert)
prep = req.prepare()
# Send the request.
- resp = self.send(prep, prefetch=prefetch, timeout=timeout, verify=verify, cert=cert)
+ resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert)
# Redirect resolving generator.
- gen = self.resolve_redirects(resp, req, prefetch, timeout, verify, cert)
+ gen = self.resolve_redirects(resp, req, stream, timeout, verify, cert)
# Resolve redirects if allowed.
history = [r for r in gen] if allow_redirects else []