Skip to content
Myr

Take advantage of the new copy method

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ian Cordasco · committed by Ian Cordasco · parent 9720898 · Browse files · 2 files+2 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+2 added−11 removed

  • other:+2 added−11 removed

2 files+2 added−11 removed

modified:requests/auth.py+1 added-7 removed
143 unmodified lines
144145 def handle_401(self, r, **kwargs):146 """Takes the given response and tries digest-auth, if needed."""147148 from .models import PreparedRequest148 num_401_calls = getattr(self, 'num_401_calls', 1)149 s_auth = r.headers.get('www-authenticate', '')150151 if 'digest' in s_auth.lower() and num_401_calls < 2:
5 unmodified lines
157 # Consume content and release the original connection158 # to allow our new request to reuse the same one.159 r.content160 r.raw.release_conn()162 prep = PreparedRequest()163 prep.method = r.request.method164 prep.url = r.request.url165 prep.body = r.request.body166 prep.headers = r.request.headers.copy()167 prep.hooks = r.request.hooks161 prep = r.request.copy()162 prep.prepare_cookies(r.cookies)163164 prep.headers['Authorization'] = self.build_digest_header(165 prep.method, prep.url)
15 unmodified lines
modified:requests/sessions.py+1 added-4 removed
72 unmodified lines
73 i = 07475 # ((resp.status_code is codes.see_other))76 while (('location' in resp.headers and resp.status_code in REDIRECT_STATI)):77 prepared_request = PreparedRequest()78 prepared_request.body = req.body79 prepared_request.headers = req.headers.copy()80 prepared_request.hooks = req.hooks77 prepared_request = req.copy()7879 resp.content # Consume socket so it can be released8081 if i >= self.max_redirects:
427 unmodified lines