From: Cory Benfield Date: Fri, 22 Feb 2013 00:33:01 +0000 (+1100) Subject: Unquote proxy usernames and passwords. X-Git-Tag: v1.2.0~36^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=577dba2bf737b1522145a1ca52d3aaf0d1fe5ed5;p=services%2Fpython-requests.git Unquote proxy usernames and passwords. --- diff --git a/requests/adapters.py b/requests/adapters.py index 2a19120..d168ad7 100644 --- a/requests/adapters.py +++ b/requests/adapters.py @@ -13,7 +13,7 @@ import socket from .models import Response from .packages.urllib3.poolmanager import PoolManager, ProxyManager from .packages.urllib3.response import HTTPResponse -from .compat import urlparse, basestring, urldefrag +from .compat import urlparse, basestring, urldefrag, unquote from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers, prepend_scheme_if_needed, get_auth_from_url) from .structures import CaseInsensitiveDict @@ -148,8 +148,8 @@ class HTTPAdapter(BaseAdapter): return url def add_headers(self, request, **kwargs): - """Add any headers needed by the connection. Currently this only adds a - Host: header if a proxy is being used.""" + """Add any headers needed by the connection. Currently this adds a + Proxy-Authorization header.""" proxies = kwargs.get('proxies', {}) if proxies is None: @@ -159,6 +159,10 @@ class HTTPAdapter(BaseAdapter): username, password = get_auth_from_url(proxy) if username and password: + # Proxy auth usernames and passwords will be urlencoded, we need + # to decode them. + username = unquote(username) + password = unquote(password) request.headers['Proxy-Authorization'] = _basic_auth_str(username, password)