Repository navigation
Conversation
Proxy-Authorization and proxy custom headers were only added to the first request in `execute_request`. On a cross-origin redirect, `remove_sensitive_headers` strips Proxy-Authorization and nothing put it back, so an http hop through an authenticated proxy got a 407. Apply the proxy headers in `HyperService`, below the redirect layer, so each hop gets the headers of the proxy that intercepts its own URI. Closes seanmonstar#2177
leoleducq
marked this pull request as draft
November 20, 2026 08:14
leoleducq
marked this pull request as ready for review
November 20, 2026 09:04
Owner
|
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.
Left unchecked on purpose: the description and the comment in the diff were drafted with an AI assistant. The fix and the regression test were checked by running them (the test fails on master and passes here). Happy to rewrite anything in my own words if you prefer.
Fixes #2177.
Problem
Through an HTTP proxy that requires basic auth (
Proxy::http("http://user:pass@proxy"),HTTP_PROXY, ...), a redirect to anhttp://URL on another host gets407 Proxy Authentication Required:http://a/redirects tohttp://b/: the second request reaches the proxy withoutProxy-Authorization.https://a/redirects tohttp://b/: the first hop authenticates in the CONNECT tunnel, thehttphop is sent withoutProxy-Authorization.Requesting the final URL directly works.
execute_requestadds the proxy headers (proxy_auth,proxy_custom_headers) to the first request only. On a cross-origin redirect,remove_sensitive_headersstripsProxy-Authorization, and nothing computes it again for the next hop.Stripping it is right for a header the caller set by hand, as discussed in #2177. This change keeps that. The credentials configured on the proxy are different: they belong to the proxy, and should go with every request sent to it, as on the first request. curl (
--proxy-user) and Go'snet/http(credentials in the proxy URL) send them on every request that goes through the proxy, redirects included.Fix
Move
proxy_authandproxy_custom_headersfromClient::execute_requestintoHyperService::call.HyperServicesits belowFollowRedirect, likeCookieService, so each hop gets the headers of the proxy that intercepts its own URI. The rules don't change:httpdestinations only, the first matching proxy only, and aProxy-Authorizationalready on the request is kept.Test
http_proxy_basic_auth_on_cross_host_redirectintests/proxy.rs: the test server acts as the proxy, answers 407 whenProxy-Authorizationis missing, and redirectshttp://hyper.rs.local/redirecttohttp://other.rs.local/dst. It fails onmaster(407) and passes with this change.cargo fmt --checkandcargo test(default features, andcookies,blocking,gzip,stream,socks) pass.