Commit 838c22fb authored by Vincent Pelletier's avatar Vincent Pelletier

HTTP: Distrust environment

By default, requests accesses user's .netrc . Disable this using the only
available (though undocumented) way: by having requests distrust the
environment. An unfortunate side-effect is that it will now also ignore
proxy settings (which do come from the environment variables, which would
be fine to access for me, unlike the .netrc).
parent 91cdbde6
...@@ -206,15 +206,16 @@ def checkHttpStatus( ...@@ -206,15 +206,16 @@ def checkHttpStatus(
parsed_url = urlparse(url) parsed_url = urlparse(url)
hostname = parsed_url.hostname hostname = parsed_url.hostname
request_kw = {"timeout": timeout} request_kw = {"timeout": timeout}
session = requests.Session()
session.trust_env = False
request_kw["session"] = session
# SNI Support # SNI Support
if parsed_url.scheme == "https": if parsed_url.scheme == "https":
# Provide SNI support # Provide SNI support
base_url = urlunsplit( base_url = urlunsplit(
(parsed_url.scheme, parsed_url.netloc, "", "", "") (parsed_url.scheme, parsed_url.netloc, "", "", "")
) )
session = requests.Session()
session.mount(base_url, ForcedIPHTTPSAdapter(dest_ip=ip)) session.mount(base_url, ForcedIPHTTPSAdapter(dest_ip=ip))
request_kw["session"] = session
ip_url = url ip_url = url
elif parsed_url.scheme == "http": elif parsed_url.scheme == "http":
# Force IP location # Force IP location
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment