From 90f73378582e4e2cbc75a189a2cfa7826824f29e Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Sat, 22 Mar 2014 21:11:33 +0000 Subject: [PATCH] Style changes thanks to @sigmavirus24. --- requests/sessions.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/requests/sessions.py b/requests/sessions.py index 65902d87..79ea7773 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