slachiewicz opened a new pull request, #957: URL: https://github.com/apache/maven-wagon/pull/957
Fixes #956. Headers configured for a repository (`setHttpHeaders`, `<httpConfiguration>` method headers) were set on every request, and HttpClient's redirect handling copied them onto the redirected request, so a repository that redirected to another host received them there too. Those headers are often credentials. `AbstractHttpClientWagon` now puts the repository origin and the configured header names into the per-request `HttpClientContext`, and a request interceptor registered once on the shared client, `OriginScopedHeadersInterceptor`, removes those headers from any request whose target host differs from the origin in scheme, host or effective port. A redirect within the same origin keeps them. `User-Agent` is exempt, since it identifies the client rather than the repository. Basic authentication through the credentials provider is unchanged; HttpClient already scopes it by host. `-Dmaven.wagon.http.originScopedHeaders=false` restores the previous behaviour. Two tests in `HttpWagonTestCase` cover a redirect to another origin (header must not arrive) and a redirect within the origin (header must arrive). `wagon-http-lightweight` follows redirects inside `HttpURLConnection` and cannot apply the same rule; its test class opts out of the two tests and the gap remains documented in #956. 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.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
