fix: route the proxy check through the proxy for both URL schemes - #62
Merged
Conversation
requests selects the proxy from the proxies mapping by the URL scheme. The mapping was keyed only by the configured schema, so with default settings (http schema, https test URL) no proxy was selected at all: the check ran over a direct connection, the peername verification rejected every candidate and get() always failed. Broken since 1.2.1. Build the mapping for both http and https so the test URL is always routed through the proxy, whatever its scheme. Bump version to 1.2.3. Fixes #61
Run unit tests on every push and pull request across supported Python versions. Tests hitting real proxy-list sites are skipped on CI to keep the workflow deterministic.
The CI workflow relies on network-dependent tests being skipped when CI=true, but the skip markers were missing on this branch -- the list filter tests still hit real proxy-list sites, making CI runs flaky. Also add a success-path test: a proxy whose IP answers the check is returned by get(), with the peer socket mocked.
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.
Fixes #61
Problem
With default settings
get()always failed withFreeProxyException: There are no working proxies at this time.after scanning the full list (~2 minutes), no matter how many proxies were actually working. Broken since 1.2.1.requestsselects the proxy from theproxiesmapping by the scheme of the requested URL. The check built the mapping keyed only by the configured schema, so with the defaulthttpschema and the defaulthttps://www.google.comtest URL no proxy was selected at all — the check ran over a direct connection and the peername verification (correctly) rejected every candidate.Fix
Build the proxies mapping for both
httpandhttps, so the test URL is always routed through the proxy regardless of its scheme.Verification
FreeProxy().get()returns a working proxy in ~4 s (previously ~115 s scan ending in an exception)originon httpbin.org/ipAlso included