Skip to content

Commit 249bad0

Browse files
natanrajchtemoto
authored andcommitted
proxy: urllib getproxies works with OS specific sources (like Windows registry)
1 parent 9bf300c commit 249bad0

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎python2/httplib2/__init__.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,7 @@ def proxy_info_from_environment(method="http"):
10901090
if method not in ["http", "https"]:
10911091
return
10921092

1093-
env_var = method + "_proxy"
1094-
url = os.environ.get(env_var, os.environ.get(env_var.upper()))
1093+
url = urllib.getproxies().get(method)
10951094
if not url:
10961095
return
10971096
return proxy_info_from_url(url, method, None)
@@ -1628,7 +1627,7 @@ def __init__(
16281627
`proxy_info` may be:
16291628
- a callable that takes the http scheme ('http' or 'https') and
16301629
returns a ProxyInfo instance per request. By default, uses
1631-
proxy_nfo_from_environment.
1630+
proxy_info_from_environment.
16321631
- a ProxyInfo instance (static proxy config).
16331632
- None (proxy disabled).
16341633

‎python3/httplib2/__init__.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import ssl
4141
import sys
4242
import time
43-
import urllib.parse
43+
import urllib.parse, urllib.request
4444
import zlib
4545

4646
try:
@@ -1071,8 +1071,7 @@ def proxy_info_from_environment(method="http"):
10711071
if method not in ("http", "https"):
10721072
return
10731073

1074-
env_var = method + "_proxy"
1075-
url = os.environ.get(env_var, os.environ.get(env_var.upper()))
1074+
url = urllib.request.getproxies().get(method)
10761075
if not url:
10771076
return
10781077
return proxy_info_from_url(url, method, noproxy=None)

0 commit comments

Comments
 (0)