Repository navigation
Fix proxy URLs that start with "http" but carry no scheme - #1201
Open
Shriraj1901 wants to merge 1 commit into
Open
Shriraj1901 wants to merge 1 commit into
Shriraj1901 wants to merge 1 commit into
Conversation
get_pool_manager() decided whether http_proxy or https_proxy already had a
scheme by checking startswith("http"). A bare proxy host such as
"httpproxy.corp:3128" or "http-proxy.corp:3128" matched, was handed to
urllib3 as is, and the client failed with ProxySchemeUnknown. The same check
did not recognize an upper case "HTTP://" prefix, so that value became
"http://HTTP://proxy..." and urllib3 read the host as "http".
A scheme is now recognized only when the value contains "://". Values with an
explicit scheme, and bare hosts that really have none, behave as before.
This branch has not been deployed
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.
get_pool_manager() decided whether http_proxy or https_proxy already had a scheme by checking startswith("http"). A bare proxy host such as "httpproxy.corp:3128" or "http-proxy.corp:3128" matched, was handed to urllib3 as is, and the client failed with ProxySchemeUnknown. The same check did not recognize an upper case "HTTP://" prefix, so that value became "http://HTTP://proxy..." and urllib3 read the host as "http".
A scheme is now recognized only when the value contains "://". Values with an explicit scheme, and bare hosts that really have none, behave as before.
Summary
Checklist
Delete items not relevant to your PR:
Note
Low Risk
Localized change to HTTP proxy URL normalization in
httputil.get_pool_managerwith new unit tests; no auth or data-path impact.Overview
HTTP/HTTPS proxy URLs are normalized using a stricter scheme rule in
get_pool_manager().Previously, bare proxy hosts whose names started with
http(for examplehttpproxy.corp:3128) were treated as already having a scheme and passed through to urllib3, which raisedProxySchemeUnknown. Uppercase values likeHTTP://proxy.corp:3128could also be double-prefixed and parsed with the wrong host.The driver now adds a default scheme only when the value lacks
://, via_with_proxy_scheme. Explicit schemes are left unchanged; barehost:portvalues gethttp://orhttps://as appropriate.HTTP_PROXY/HTTPS_PROXYfollow the same path when they are passed into pool creation. Parametrized unit tests assert the parsed proxy scheme, host, and port.Reviewed by Cursor Bugbot for commit 276a157. Bugbot is set up for automated code reviews on this repo. Configure here.