Fix calibre not supporting different http and https proxies. Fixes #960173 (Proxy error with multiple "*_proxy" environment variables under GNU/Linux)

This commit is contained in:
Kovid Goyal 2012-03-20 18:51:53 +05:30
parent 9915d4b963
commit 6b12bc2e56

View File

@ -381,12 +381,15 @@ def browser(honor_time=True, max_time=2, mobile_browser=False, user_agent=None):
user_agent = USER_AGENT_MOBILE if mobile_browser else USER_AGENT user_agent = USER_AGENT_MOBILE if mobile_browser else USER_AGENT
opener.addheaders = [('User-agent', user_agent)] opener.addheaders = [('User-agent', user_agent)]
proxies = get_proxies() proxies = get_proxies()
to_add = {}
http_proxy = proxies.get('http', None) http_proxy = proxies.get('http', None)
if http_proxy: if http_proxy:
opener.set_proxies({'http':http_proxy}) to_add['http'] = http_proxy
https_proxy = proxies.get('https', None) https_proxy = proxies.get('https', None)
if https_proxy: if https_proxy:
opener.set_proxies({'https':https_proxy}) to_add['https'] = https_proxy
if to_add:
opener.set_proxies(to_add)
return opener return opener