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.
This pull request refactors our URL matching for proxy lookups.
It adds a utility class
URLMatcher
that handles matching against the proxy keys that we currently support.It's best explained through some examples...
Here's why we care about it...
transport_for_url
is much more clear now.NO_PROXY
, and allow us to resolve Don't callshould_not_be_proxied
on each request #1062 neatly.Note that some of the cases in
test_proxies_parameter
have changed, but they're all odd cases, where the desired behaviour is ambiguous, and I don't think we're actually regressing in any of those case.proxies={"http://example.com:80": httpx.Proxy(...)}
, then we now only match if the requested URL includes an explicit port 80. That seems pretty reasonable. It's an odd key to use in any case.proxies={"http://example.com": httpx.Proxy(...)}
, then we now match bothexample.com
andexample.com:<some port>
to the proxy. That seems like an improvement in expected behaviour.