Skip to content
Myr

Unquote proxy usernames and passwords.

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

authored by Cory Benfield · committed by Cory Benfield · parent 178ff62 · Browse files · 1 file+7 added−3 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+7 added−3 removed

  • other:+7 added−3 removed

1 file+7 added−3 removed

modified:requests/adapters.py+7 added-3 removed
11 unmodified lines
1213from .models import Response14from .packages.urllib3.poolmanager import PoolManager, ProxyManager15from .packages.urllib3.response import HTTPResponse16from .compat import urlparse, basestring, urldefrag16from .compat import urlparse, basestring, urldefrag, unquote17from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,18 prepend_scheme_if_needed, get_auth_from_url)19from .structures import CaseInsensitiveDict20from .packages.urllib3.exceptions import MaxRetryError
126 unmodified lines
147148 return url149150 def add_headers(self, request, **kwargs):151 """Add any headers needed by the connection. Currently this only adds a152 Host: header if a proxy is being used."""151 """Add any headers needed by the connection. Currently this adds a152 Proxy-Authorization header."""153 proxies = kwargs.get('proxies', {})154155 if proxies is None:156 proxies = {}
1 unmodified line
158 proxy = proxies.get(urlparse(request.url).scheme)159 username, password = get_auth_from_url(proxy)160161 if username and password:162 # Proxy auth usernames and passwords will be urlencoded, we need163 # to decode them.164 username = unquote(username)165 password = unquote(password)166 request.headers['Proxy-Authorization'] = _basic_auth_str(username,167 password)168169 def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
73 unmodified lines