Skip to content

Commit fd46c8f

Browse files
committed
Merge branch 'proxy-support' into develop
Adding true support for HTTP and HTTPS proxies
2 parents 520ea3d + 101bde5 commit fd46c8f

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
@@ -95,13 +95,15 @@ def __init__(self, domain, realm, consumer_key, consumer_secret,
9595
self._cookie_jar = cookielib.LWPCookieJar()
9696
opener = \
9797
urllib2.build_opener(urllib2.HTTPCookieProcessor(self._cookie_jar))
98-
# Add an HTTP proxy if necessary:
98+
# Add an HTTP[S] proxy if necessary:
99+
proxies = {}
99100
if http_proxy:
100-
http_proxy_handler = urllib2.ProxyHandler({'http': http_proxy})
101-
opener.add_handler(http_proxy_handler)
101+
proxies['http'] = http_proxy
102102
if https_proxy:
103-
https_proxy_handler = urllib2.ProxyHandler({'https': https_proxy})
104-
opener.add_handler(https_proxy_handler)
103+
proxies['https'] = https_proxy
104+
if proxies:
105+
proxy_handler = urllib2.ProxyHandler(proxies)
106+
opener.add_handler(proxy_handler)
105107

106108
urllib2.install_opener(opener)
107109

0 commit comments

Comments
 (0)