Skip to content

Commit 101bde5

Browse files
committed
Added http and https proxy support
1 parent 74b7394 commit 101bde5

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

ox3apiclient/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
9292
self._cookie_jar = cookielib.LWPCookieJar()
9393
opener = \
9494
urllib2.build_opener(urllib2.HTTPCookieProcessor(self._cookie_jar))
95-
# Add an HTTP proxy if necessary:
95+
# Add an HTTP[S] proxy if necessary:
96+
proxies = {}
9697
if http_proxy:
97-
http_proxy_handler = urllib2.ProxyHandler({'http': http_proxy})
98-
opener.add_handler(http_proxy_handler)
98+
proxies['http'] = http_proxy
9999
if https_proxy:
100-
https_proxy_handler = urllib2.ProxyHandler({'https': https_proxy})
101-
opener.add_handler(https_proxy_handler)
100+
proxies['https'] = https_proxy
101+
if proxies:
102+
proxy_handler = urllib2.ProxyHandler(proxies)
103+
opener.add_handler(proxy_handler)
102104

103105
urllib2.install_opener(opener)
104106

0 commit comments

Comments
 (0)