Skip to content

Fix: Strip proxies when redirect URL matches no_proxy#7194

Open
atulk-code wants to merge 1 commit intopsf:mainfrom
atulk-code:fix/no-proxy-on-redirect
Open

Fix: Strip proxies when redirect URL matches no_proxy#7194
atulk-code wants to merge 1 commit intopsf:mainfrom
atulk-code:fix/no-proxy-on-redirect

Conversation

@atulk-code
Copy link

This fixes issue #3296 where the no_proxy environment variable was ignored on 302 redirects.

The root cause was in resolve_proxies() - when should_bypass_proxies() returned True, the function only avoided adding new environment proxies, but did not remove existing proxies that were passed in from the original request.

Changes:

  • Modified resolve_proxies() to pop scheme-specific and 'all' proxies when the URL matches no_proxy configuration
  • Added 7 new test cases in TestResolveProxies class to verify the fix

This ensures that when following a redirect from a proxied URL to an internal URL that matches no_proxy, the proxy configuration is correctly stripped for the internal request.

This fixes issue psf#3296 where the no_proxy environment variable was
ignored on 302 redirects.

The root cause was in resolve_proxies() - when should_bypass_proxies()
returned True, the function only avoided adding new environment proxies,
but did not remove existing proxies that were passed in from the original
request.

Changes:
- Modified resolve_proxies() to pop scheme-specific and 'all' proxies
  when the URL matches no_proxy configuration
- Added 7 new test cases in TestResolveProxies class to verify the fix

This ensures that when following a redirect from a proxied URL to an
internal URL that matches no_proxy, the proxy configuration is correctly
stripped for the internal request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant