]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Fix environment proxies (#2741)
authorKar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
Thu, 14 Dec 2023 14:04:04 +0000 (09:04 -0500)
committerGitHub <noreply@github.com>
Thu, 14 Dec 2023 14:04:04 +0000 (14:04 +0000)
* Add red test

* Make the test pass

* Lint

* chanelog

---------

Co-authored-by: Karen Petrosyan <92274156+karosis88@users.noreply.github.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
CHANGELOG.md
httpx/_utils.py
tests/test_utils.py

index 18d0e84a98315f1be094ef31c7682b75b05ac627..950d3898cf1b3afbfe6cb0869581377efa91e731 100644 (file)
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
 ### Fixed
 
+* Handle `NO_PROXY` envvar cases when a fully qualified URL is supplied as the value. (#2741)
 * Allow URLs where username or password contains unescaped '@'. (#2986)
 * Ensure ASGI `raw_path` does not include URL query component. (#2999)
 * Ensure `Response.iter_text()` cannot yield empty strings. (#2998)
index a0bc2c5b6d8869fd99f984026526834eb62d72e5..21241967e36c56d220cb9d589eb22bb44d935f09 100644 (file)
@@ -227,7 +227,9 @@ def get_environment_proxies() -> typing.Dict[str, typing.Optional[str]]:
             #   (But not "wwwgoogle.com")
             # NO_PROXY can include domains, IPv6, IPv4 addresses and "localhost"
             #   NO_PROXY=example.com,::1,localhost,192.168.0.0/16
-            if is_ipv4_hostname(hostname):
+            if "://" in hostname:
+                mounts[hostname] = None
+            elif is_ipv4_hostname(hostname):
                 mounts[f"all://{hostname}"] = None
             elif is_ipv6_hostname(hostname):
                 mounts[f"all://[{hostname}]"] = None
index bbaf6007b54b93f533eb467bdaf28685a79c77a8..5391f9c22d4d91d87e41d5d8f97c71959b67bb79 100644 (file)
@@ -197,6 +197,7 @@ def test_get_ssl_cert_file():
         ({"no_proxy": "localhost"}, {"all://localhost": None}),
         ({"no_proxy": "github.com"}, {"all://*github.com": None}),
         ({"no_proxy": ".github.com"}, {"all://*.github.com": None}),
+        ({"no_proxy": "http://github.com"}, {"http://github.com": None}),
     ],
 )
 def test_get_environment_proxies(environment, proxies):