requests icon indicating copy to clipboard operation
requests copied to clipboard

requests ignores no_proxy which contains a IPv6 CIDR

Open derekhiggins opened this issue 3 years ago • 1 comments

python requests supports a no_proxy environment variable with a IPv4 CIDR e.g.

e.g

+ export http_proxy no_proxy
+ http_proxy=http://localhost
+ python -c 'import requests.utils ; print(requests.utils.should_bypass_proxies("http://1.2.3.4", None))'
False
+ no_proxy=1.2.3.0/24
+ python -c 'import requests.utils ; print(requests.utils.should_bypass_proxies("http://1.2.3.4", None))'
True

but doesn't support a IPv6 CIDR e.g.

+ http_proxy=http://localhost
+ python -c 'import requests.utils ; print(requests.utils.should_bypass_proxies("http://[1:2:3::4]", None))'
False
+ no_proxy=1:2:3::/64
+ python -c 'import requests.utils ; print(requests.utils.should_bypass_proxies("http://[1:2:3::4]", None))'
False

Expected Result

For proxy to be bypassed if a the url matches the IPv6 CIDR in no_proxy

Actual Result

IPv6 CIDR ignored

Reproduction Steps

as above

System Information

[derekh@laptop ~]$ python -m requests.help /usr/lib/python3.11/site-packages/requests/help.py:24: DeprecationWarning: 'urllib3.contrib.pyopenssl' module is deprecated and will be removed in a future release of urllib3 2.x. Read more in this issue: https://github.com/urllib3/urllib3/issues/2680 from urllib3.contrib import pyopenssl { "chardet": { "version": "5.1.0" }, "charset_normalizer": { "version": "2.1.0" }, "cryptography": { "version": "37.0.2" }, "idna": { "version": "3.3" }, "implementation": { "name": "CPython", "version": "3.11.1" }, "platform": { "release": "6.0.13-300.fc37.x86_64", "system": "Linux" }, "pyOpenSSL": { "openssl_version": "30000050", "version": "21.0.0" }, "requests": { "version": "2.28.1" }, "system_ssl": { "version": "30000050" }, "urllib3": { "version": "1.26.12" }, "using_charset_normalizer": false, "using_pyopenssl": true }

derekhiggins avatar Dec 21 '22 12:12 derekhiggins

Proposed a fix here https://github.com/psf/requests/pull/5953

derekhiggins avatar Dec 21 '22 12:12 derekhiggins