Skip to content
Myr

Merge pull request #1892 from Lukasa/netrcauth

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

Repopulate ~/.netrc auth.

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 4f12bfa, d9f34c6 · Browse files · 1 file+15 added−0 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+15 added−0 removed

  • other:+15 added−0 removed

1 file+15 added−0 removed

modified:requests/sessions.py+15 added
156 unmodified lines
157 prepared_request, resp.raw)158 prepared_request._cookies.update(self.cookies)159 prepared_request.prepare_cookies(prepared_request._cookies)160161 # If we get redirected to a new host, we should strip out any162 # authentication headers.163 original_parsed = urlparse(resp.request.url)164 redirect_parsed = urlparse(url)165166 if (original_parsed.hostname != redirect_parsed.hostname and167 'Authorization' in headers):168 del headers['Authorization']169170 # However, .netrc might have more auth for us. Let's get it if it171 # does.172 new_auth = get_netrc_auth(url) if self.trust_env else None173 if new_auth is not None:174 prepared_request.prepare_auth(new_auth)175176 resp = self.send(177 prepared_request,178 stream=stream,179 timeout=timeout,
389 unmodified lines