Skip to content

Use HttpHeaders.copyOf in DefaultClientResponseBuilder - #37087

Open
yashmehla wants to merge 1 commit into
spring-projects:mainfrom
yashmehla:fix-37086-clientresponse-mutate
Open

Use HttpHeaders.copyOf in DefaultClientResponseBuilder#37087
yashmehla wants to merge 1 commit into
spring-projects:mainfrom
yashmehla:fix-37086-clientresponse-mutate

Conversation

@yashmehla

Copy link
Copy Markdown

Fixes #37086.

ClientResponse.mutate() currently modifies the original response's headers because DefaultClientResponseBuilder initializes its headers using the HttpHeaders(HttpHeaders) constructor, which shares the underlying headers.

This change uses HttpHeaders.copyOf(...) so that the builder works with an independent copy of the original response's headers.

A regression test has been added to verify that mutating the builder does not modify the original response's headers or cookies.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 25, 2026
Signed-off-by: yashmehla <mehlayash@icloud.com>
@yashmehla
yashmehla force-pushed the fix-37086-clientresponse-mutate branch from ddf74e5 to 4aa76f5 Compare July 25, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientResponse.mutate() builder can modify originalResponse headers.

2 participants