diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-12-14 09:37:38 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-12-14 09:37:38 +0000 |
commit | 0ae2b58f2dcb7eda076ddfc22b67d721d274e2bb (patch) | |
tree | 916b8f43c7bb540f24b911f8e0038031c828eb2c /swiftclient/client.py | |
parent | 38ae02928ddc72a1d8ed5a36c3de0eaa69111c32 (diff) | |
parent | 716b4e722c98396dc1477a04120eb0fedf388799 (diff) | |
download | python-swiftclient-0ae2b58f2dcb7eda076ddfc22b67d721d274e2bb.tar.gz |
Merge "Enable usage of proxies defined in environment (http(s)_proxy)."
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r-- | swiftclient/client.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py index 0eef678..dc457c6 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -29,6 +29,7 @@ from httplib import HTTPException, HTTPConnection, HTTPSConnection from time import sleep, time from swiftclient.exceptions import ClientException, InvalidHeadersException +from swiftclient.utils import get_environ_proxies try: from swiftclient.https_connection import HTTPSConnectionNoSSLComp @@ -140,8 +141,13 @@ def http_connection(url, proxy=None, ssl_compression=True): """ url = encode_utf8(url) parsed = urlparse(url) - proxy_parsed = urlparse(proxy) if proxy else None - host = proxy_parsed if proxy else parsed.netloc + if proxy: + proxy_parsed = urlparse(proxy) + else: + proxies = get_environ_proxies(parsed.netloc) + proxy = proxies.get(parsed.scheme, None) + proxy_parsed = urlparse(proxy) if proxy else None + host = proxy_parsed.netloc if proxy else parsed.netloc if parsed.scheme == 'http': conn = HTTPConnection(host) elif parsed.scheme == 'https': |