Skip to content

[3.x] Keep configured HTTP headers on the repository origin across redirects - #958

Merged
slachiewicz merged 1 commit into
apache:wagon-3.xfrom
slachiewicz:http-headers-origin-scoped-3.x
Sep 3, 2026
Merged

[3.x] Keep configured HTTP headers on the repository origin across redirects#958
slachiewicz merged 1 commit into
apache:wagon-3.xfrom
slachiewicz:http-headers-origin-scoped-3.x

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

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=false restores the previous behaviour. Two tests cover the cross-origin and same-origin redirect cases; wagon-http-lightweight opts out as on master.

Verified: mvn -pl wagon-providers/wagon-http-shared,wagon-provider-test,wagon-providers/wagon-http -am verify → green, 60 tests in HttpWagonTest.

This change was created with AI assistance.

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)
@slachiewicz slachiewicz added bug Something isn't working maintenance labels Sep 2, 2026
@slachiewicz
slachiewicz merged commit daeba57 into apache:wagon-3.x Sep 3, 2026
10 of 16 checks passed
@github-actions github-actions Bot added this to the 3.5.4 milestone Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant