who did this
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 f74f5e3 · Browse files · 1 file·+17 added−9 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+17 added−9 removed
- other:+17 added−9 removed
Provenance
- Commit
c042c08- Tree
d44a9d7- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
f74f5e3
1 file changed+17 added−9 removed
modified:requests/sessions.py+17 added-9 removed
25 unmodified lines26 from .utils import requote_uri, get_environ_proxies, get_netrc_auth27 28 from .status_codes import codes29 REDIRECT_STATI = (30- codes.moved, # 30131- codes.found, # 30232- codes.other, # 30333- codes.temporary_moved, # 30730+ codes.moved, # 30131+ codes.found, # 30232+ codes.other, # 30333+ codes.temporary_moved, # 30734 )35 DEFAULT_REDIRECT_LIMIT = 3036 37 441 unmodified lines479 # Guard against that specific failure case.480 if not isinstance(request, PreparedRequest):481 raise ValueError('You can only send PreparedRequests.')482 483- # Set up variables needed for resolve_redirects and dispatching of484- # hooks483+ # Set up variables needed for resolve_redirects and dispatching of hooks484 allow_redirects = kwargs.pop('allow_redirects', True)485 stream = kwargs.get('stream')486 timeout = kwargs.get('timeout')487 verify = kwargs.get('verify')5 unmodified lines493 adapter = self.get_adapter(url=request.url)494 495 # Start time (approximately) of the request496 start = datetime.utcnow()497+498 # Send the request499 r = adapter.send(request, **kwargs)500+501 # Total elapsed time of the request (approximately)502 r.elapsed = datetime.utcnow() - start503 504 # Response manipulation hooks505 r = dispatch_hook('response', hooks, r, **kwargs)506 507 # Persist cookies508 if r.history:509+510 # If the hooks create history then we want those cookies too511 for resp in r.history:512 extract_cookies_to_jar(self.cookies, resp.request, resp.raw)513+514 extract_cookies_to_jar(self.cookies, request, r.raw)515 516 # Redirect resolving generator.514- gen = self.resolve_redirects(r, request, stream=stream,515- timeout=timeout, verify=verify, cert=cert,516- proxies=proxies)517+ gen = self.resolve_redirects(r, request,518+ stream=stream,519+ timeout=timeout,520+ verify=verify,521+ cert=cert,522+ proxies=proxies)523 524 # Resolve redirects if allowed.525 history = [resp for resp in gen] if allow_redirects else []526 25 unmodified lines552 def mount(self, prefix, adapter):553 """Registers a connection adapter to a prefix.554 555 Adapters are sorted in descending order by key length."""556+557 self.adapters[prefix] = adapter558 keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]559+560 for key in keys_to_move:561 self.adapters[key] = self.adapters.pop(key)562 563 def __getstate__(self):11 unmodified lines