Skip to content
Myr

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

1 file+17 added−9 removed

modified:requests/sessions.py+17 added-9 removed
25 unmodified lines
26from .utils import requote_uri, get_environ_proxies, get_netrc_auth2728from .status_codes import codes29REDIRECT_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)35DEFAULT_REDIRECT_LIMIT = 303637
441 unmodified lines
479 # Guard against that specific failure case.480 if not isinstance(request, PreparedRequest):481 raise ValueError('You can only send PreparedRequests.')482483 # 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 lines
493 adapter = self.get_adapter(url=request.url)494495 # Start time (approximately) of the request496 start = datetime.utcnow()497498 # Send the request499 r = adapter.send(request, **kwargs)500501 # Total elapsed time of the request (approximately)502 r.elapsed = datetime.utcnow() - start503504 # Response manipulation hooks505 r = dispatch_hook('response', hooks, r, **kwargs)506507 # Persist cookies508 if r.history:509510 # 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)513514 extract_cookies_to_jar(self.cookies, request, r.raw)515516 # 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)523524 # Resolve redirects if allowed.525 history = [resp for resp in gen] if allow_redirects else []526
25 unmodified lines
552 def mount(self, prefix, adapter):553 """Registers a connection adapter to a prefix.554555 Adapters are sorted in descending order by key length."""556557 self.adapters[prefix] = adapter558 keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]559560 for key in keys_to_move:561 self.adapters[key] = self.adapters.pop(key)562563 def __getstate__(self):
11 unmodified lines