Repository navigation
ngclient: Accept proxy variables without a scheme - #3051
Closed
BahaaMattar wants to merge 1 commit into
Closed
BahaaMattar wants to merge 1 commit into
BahaaMattar wants to merge 1 commit into
Conversation
Proxy environment variables are often set without a scheme, for example https_proxy=proxy.example:3128. The previous requests based fetcher, curl and most other clients treat that as a http:// proxy, but ProxyEnvironment passed the value as is to urllib3, which raises ProxySchemeUnknown. Urllib3Fetcher then failed every download with a DownloadError. Add "http://" to proxy URLs that have no scheme. Fixes theupdateframework#3050 Signed-off-by: Bahaa Mattar <bahaa.kmattar@gmail.com>
Member
|
Thanks but I think I'll consider this "works as designed", context: #3050 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the changes being introduced by the pull request:
Proxy environment variables are often set without a scheme, for example
https_proxy=proxy.example:3128. The previousrequestsbased fetcher (whichProxyEnvironmentaims to keep parity with) and curl treat that as anhttp://proxy.ProxyEnvironmentpassed the value as is to urllib3, whoseProxyManagerraisesProxySchemeUnknown, soUrllib3Fetcherfailed every download with aDownloadError.This adds a small helper,
_with_scheme(), used where_get_proxy()returns the*_proxy/all_proxyvalue: a proxy URL without://getshttp://prepended, anything that already has a scheme is returned unchanged.test_proxy_without_scheme(new) sets a scheme-lesshttpsproxy and a scheme-lessallproxy with credentials, and checks the pool managers are created forhttp://localhost:8888andhttp://user:secret@localhost:9999. It fails on currentdevelopwithProxySchemeUnknownand passes with the change. I also checked end to end against a local HTTP server acting as the proxy: withhttp_proxy=127.0.0.1:<port>,Urllib3Fetcher.download_bytes()fails withDownloadErrorbefore the change, and after it the request reaches the proxy (the proxy seesGET http://tuf.example.invalid/timestamp.json).Locally: the full unittest suite (207 tests) passes,
coverage report --fail-under 97passes,ruff check,ruff format --diffandmypyare clean on the changed files.Fixes #3050