[3.x] Keep configured HTTP headers on the repository origin across redirects - #958
Merged
slachiewicz merged 1 commit intoSep 3, 2026
Conversation
Fixes apache#956. HttpClient copies the headers of the original request onto every redirected request, so headers configured for a repository through setHttpHeaders or the method configuration followed redirects to other hosts. The wagon now records the repository origin and the configured header names in the request context, and an interceptor on the shared client removes those headers from any request whose target differs from the origin in scheme, host or effective port. User-Agent is exempt. Setting -Dmaven.wagon.http.originScopedHeaders=false restores the previous behaviour. (cherry picked from commit c345af7)
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.
Backport of #957 to the 3.x line, for #956. Clean cherry-pick; the HTTP provider code is the same on both branches.
Headers configured for a repository followed redirects to other hosts. The wagon now records the repository origin and the configured header names in the request context, and an interceptor on the shared client removes those headers from requests whose target host differs from the origin in scheme, host or effective port.
-Dmaven.wagon.http.originScopedHeaders=falserestores the previous behaviour. Two tests cover the cross-origin and same-origin redirect cases;wagon-http-lightweightopts out as on master.Verified:
mvn -pl wagon-providers/wagon-http-shared,wagon-provider-test,wagon-providers/wagon-http -am verify→ green, 60 tests inHttpWagonTest.This change was created with AI assistance.