Skip to content

Commit

Permalink
proxy: urllib getproxies works with OS specific sources (like Windows…
Browse files Browse the repository at this point in the history
… registry)
  • Loading branch information
natanrajch authored and temoto committed Sep 8, 2020
1 parent 9bf300c commit 249bad0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions python2/httplib2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,7 @@ def proxy_info_from_environment(method="http"):
if method not in ["http", "https"]:
return

env_var = method + "_proxy"
url = os.environ.get(env_var, os.environ.get(env_var.upper()))
url = urllib.getproxies().get(method)
if not url:
return
return proxy_info_from_url(url, method, None)
Expand Down Expand Up @@ -1628,7 +1627,7 @@ def __init__(
`proxy_info` may be:
- a callable that takes the http scheme ('http' or 'https') and
returns a ProxyInfo instance per request. By default, uses
proxy_nfo_from_environment.
proxy_info_from_environment.
- a ProxyInfo instance (static proxy config).
- None (proxy disabled).
Expand Down
5 changes: 2 additions & 3 deletions python3/httplib2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import ssl
import sys
import time
import urllib.parse
import urllib.parse, urllib.request
import zlib

try:
Expand Down Expand Up @@ -1071,8 +1071,7 @@ def proxy_info_from_environment(method="http"):
if method not in ("http", "https"):
return

env_var = method + "_proxy"
url = os.environ.get(env_var, os.environ.get(env_var.upper()))
url = urllib.request.getproxies().get(method)
if not url:
return
return proxy_info_from_url(url, method, noproxy=None)
Expand Down

0 comments on commit 249bad0

Please sign in to comment.