Handle proxy environment variables in lower case // Resolve #3606

This commit is contained in:
Ivan Kravets
2020-07-23 19:07:29 +03:00
parent 1abc110f8a
commit c193a4ceb7

View File

@ -377,10 +377,12 @@ def _internet_on():
socket.setdefaulttimeout(timeout)
for host in PING_REMOTE_HOSTS:
try:
if os.getenv("HTTP_PROXY", os.getenv("HTTPS_PROXY")):
for var in ("HTTP_PROXY", "HTTPS_PROXY"):
if not os.getenv(var, var.lower()):
continue
requests.get("http://%s" % host, allow_redirects=False, timeout=timeout)
else:
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, 80))
return True
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, 80))
return True
except: # pylint: disable=bare-except
pass