diff --git a/src/httpx2/httpx2/_utils.py b/src/httpx2/httpx2/_utils.py index eef7b6dc..5444622b 100644 --- a/src/httpx2/httpx2/_utils.py +++ b/src/httpx2/httpx2/_utils.py @@ -65,7 +65,11 @@ 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: + addr, _, subnet = hostname.partition("/") + mounts[f"all://[{addr}]/{subnet}"] = None + else: + mounts[f"all://[{hostname}]"] = None elif hostname.lower() == "localhost": mounts[f"all://{hostname}"] = None else: diff --git a/tests/httpx2/test_utils.py b/tests/httpx2/test_utils.py index f4bbd1fa..8efbfc53 100644 --- a/tests/httpx2/test_utils.py +++ b/tests/httpx2/test_utils.py @@ -99,6 +99,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}),