Fix no_proxy to support IPV6 CIDR format
no_proxy=fe11::/16 python -c 'import httpx; c = httpx.Client()' Closes: #3221
This commit is contained in:
parent
ae1b9f6623
commit
3e53fe315d
@ -67,7 +67,13 @@ def get_environment_proxies() -> dict[str, str | None]:
|
||||
elif is_ipv4_hostname(hostname):
|
||||
mounts[f"all://{hostname}"] = None
|
||||
elif is_ipv6_hostname(hostname):
|
||||
mounts[f"all://[{hostname}]"] = None
|
||||
if "/" in hostname:
|
||||
CIDR = hostname.split("/")
|
||||
hostname = f"{CIDR[0]}"
|
||||
subnet = f"/{CIDR[1]}"
|
||||
else:
|
||||
subnet = ""
|
||||
mounts[f"all://[{hostname}]{subnet}"] = None
|
||||
elif hostname.lower() == "localhost":
|
||||
mounts[f"all://{hostname}"] = None
|
||||
else:
|
||||
|
||||
@ -100,6 +100,7 @@ def test_logging_redirect_chain(server, caplog):
|
||||
({"no_proxy": "127.0.0.1"}, {"all://127.0.0.1": None}),
|
||||
({"no_proxy": "192.168.0.0/16"}, {"all://192.168.0.0/16": None}),
|
||||
({"no_proxy": "::1"}, {"all://[::1]": None}),
|
||||
({"no_proxy": "fe11::/16"}, {"all://[fe11::]/16": None}),
|
||||
({"no_proxy": "localhost"}, {"all://localhost": None}),
|
||||
({"no_proxy": "github.com"}, {"all://*github.com": None}),
|
||||
({"no_proxy": ".github.com"}, {"all://*.github.com": None}),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user