/s/prefetch/stream
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 5b5d8a8 · Browse files · 4 files·+13 added−16 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+13 added−16 removed
- other:+13 added−16 removed
Provenance
- Commit
4c3b9df- Tree
c3d7f03- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
5b5d8a8
4 files changed+13 added−16 removed
modified:requests/adapters.py+2 added-2 removed
140 unmodified lines141 connections.142 """143 self.poolmanager.clear()144 145- def send(self, request, prefetch=True, timeout=None, verify=True, cert=None, proxies=None):145+ def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):146 """Sends PreparedRequest object. Returns Response object."""147 148 conn = self.get_connection(request.url, proxies)149 29 unmodified lines179 raise Timeout('Request timed out.')180 181 r = self.build_response(request, resp)182 183- if prefetch:183+ if not stream:184 r.content185 186 return rmodified:requests/api.py+1 added-1 removed
28 unmodified lines29 :param timeout: (optional) Float describing the timeout of the request.30 :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.31 :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.32 :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.33- :param prefetch: (optional) if ``True``, the response content will be immediately downloaded.33+ :param stream: (optional) if ``False``, the response content will be immediately downloaded.34 :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.35 """36 37 session = sessions.Session()76 unmodified linesmodified:requests/models.py+2 added-5 removed
376 unmodified lines377 #: value of a ``'Content-Encoding'`` response header.378 self.headers = CaseInsensitiveDict()379 380 #: File-like object representation of response (for advanced usage).381- #: Requires that ``prefetch=False` on the request.381+ #: Requires that ``stream=True` on the request.382 # This requirement does not apply for use internally to Requests.383 self.raw = None384 385 #: Final URL location of Response.6 unmodified lines392 #: the history of the Request. Any redirect responses will end393 #: up here. The list is sorted from the oldest to the most recent request.394 self.history = []395 396- #: The :class:`Request <Request>` that created the Response.397- # self.request = None396 397 self.reason = None398 399 #: A CookieJar of Cookies the server sent back.110 unmodified lines510 return str('')511 512 # Fallback to auto-detected encoding.513 if self.encoding is None:516- if chardet is not None:517- encoding = chardet.detect(self.content)['encoding']514+ encoding = self.apparent_encoding515 516 # Decode unicode from given encoding.517 try:518 content = str(self.content, encoding, errors='replace')67 unmodified linesmodified:requests/sessions.py+8 added-8 removed
60 unmodified lines61 62 63 class SessionRedirectMixin(object):64 65- def resolve_redirects(self, resp, req, prefetch=True, timeout=None, verify=True, cert=None):65+ def resolve_redirects(self, resp, req, stream=False, timeout=None, verify=True, cert=None):66 """Receives a Response. Returns a generator of Responses."""67 68 i = 069 51 unmodified lines121 params=req.params,122 auth=req.auth,123 cookies=req.cookies,124 allow_redirects=False,125- prefetch=prefetch,125+ stream=stream,126 timeout=timeout,127 verify=verify,128 cert=cert129 )28 unmodified lines158 #: :class:`Request <Request>`. The dictionary values may be lists for159 #: representing multivalued query parameters.160 self.params = {}161 162- #: Prefetch response content.163- self.prefetch = True162+ #: Stream response content.163+ self.stream = False164 165 #: SSL Verification.166 self.verify = True167 25 unmodified lines193 timeout=None,194 allow_redirects=True,195 proxies=None,196 hooks=None,197- prefetch=None,197+ stream=None,198 verify=None,199 cert=None):200 201 cookies = cookies or {}11 unmodified lines213 headers = merge_kwargs(headers, self.headers)214 auth = merge_kwargs(auth, self.auth)215 proxies = merge_kwargs(proxies, self.proxies)216 hooks = merge_kwargs(hooks, self.hooks)217- prefetch = merge_kwargs(prefetch, self.prefetch)217+ stream = merge_kwargs(stream, self.stream)218 verify = merge_kwargs(verify, self.verify)219 cert = merge_kwargs(cert, self.cert)220 221 # Create the Request.11 unmodified lines233 # Prepare the Request.234 prep = req.prepare()235 236 # Send the request.237- resp = self.send(prep, prefetch=prefetch, timeout=timeout, verify=verify, cert=cert)237+ resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert)238 239 # Redirect resolving generator.240- gen = self.resolve_redirects(resp, req, prefetch, timeout, verify, cert)240+ gen = self.resolve_redirects(resp, req, stream, timeout, verify, cert)241 242 # Resolve redirects if allowed.243 history = [r for r in gen] if allow_redirects else []244 100 unmodified lines