From: Cory Benfield Date: Sat, 22 Mar 2014 21:11:33 +0000 (+0000) Subject: Style changes thanks to @sigmavirus24. X-Git-Tag: v2.3.0~27^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90f73378582e4e2cbc75a189a2cfa7826824f29e;p=services%2Fpython-requests.git Style changes thanks to @sigmavirus24. --- diff --git a/requests/sessions.py b/requests/sessions.py index 65902d8..79ea777 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -221,22 +221,21 @@ class SessionRedirectMixin(object): environ_proxies = get_environ_proxies(url) scheme = urlparse(url).scheme - try: + proxy = environ_proxies.get(scheme) + + if proxy: new_proxies.setdefault(scheme, environ_proxies[scheme]) - except KeyError: - pass if 'Proxy-Authorization' in headers: del headers['Proxy-Authorization'] try: username, password = get_auth_from_url(new_proxies[scheme]) - if username and password: - headers['Proxy-Authorization'] = _basic_auth_str( - username, password - ) except KeyError: - pass + username, password = None, None + + if username and password: + headers['Proxy-Authorization'] = _basic_auth_str(username, password) return new_proxies