Enhance Proxy Handling: Use ProxyManager for HTTP and SOCKSProxyManager for SOCKS Proxies#784
Open
mcflem06 wants to merge 4 commits intoadbar:masterfrom
Open
Enhance Proxy Handling: Use ProxyManager for HTTP and SOCKSProxyManager for SOCKS Proxies#784mcflem06 wants to merge 4 commits intoadbar:masterfrom
mcflem06 wants to merge 4 commits intoadbar:masterfrom
Conversation
Owner
|
@mcflem06 This is an interesting feature but could you please make sure the tests pass? |
Author
|
Yep, let me take a look at the tests |
Owner
|
@mcflem06 Are you still working on it? |
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.
Summary:
Users can now pass a proxy URL directly to functions such as fetch_url and fetch_response, as well as the buffered download functions. This enhancement enables more granular control over the proxy settings on a per-request basis, rather than relying solely on global or environment variables.
Changes:
Enhanced Proxy Parameter Support:
Users can now pass a proxy parameter directly to key functions (fetch_url, fetch_response, and the buffered download functions). This provides greater flexibility by allowing per-request proxy configuration rather than relying solely on environment variables.
pycurl Support:
pycurl branch in _send_pycurl_request has been updated to handle proxies as well. The function now sets the PRE_PROXY option based on the provided proxy parameter or falls back to the global PROXY_URL if none is passed.
Conditional Manager Selection:
The create_pool function now inspects the proxy URL. If it starts with "socks", it imports and uses SOCKSProxyManager; otherwise, it falls back to ProxyManager for HTTP proxies.
Logging Improvements:
Added logging to indicate which proxy manager is being used and the effective proxy value.
Code Refactoring:
Minor refactoring for clarity and to ensure that the effective proxy value is consistently used in pool creation.
Motivation:
Pulling data from news sites is an easy way to get your local IP banned. This updated enables a user to pass 'proxy' into various functions, and ensure the correct proxy manager is used based on the proxy URL, thereby allowing proper support for both HTTP and SOCKS proxies.
Testing: