Skip to content

Copy cookies in RenderingResponse.from() - #37378

Open
noojung wants to merge 1 commit into
spring-projects:mainfrom
noojung:rendering-response-from-cookies
Open

noojung wants to merge 1 commit into
spring-projects:mainfrom
noojung:rendering-response-from-cookies

Conversation

@noojung

@noojung noojung commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Overivew

RenderingResponse.from() does not copy the cookies of the given response, unlike ServerResponse.from(). As a result, a HandlerFilterFunction that rebuilds a rendering response to add a shared model attribute drops cookies set by the handler.

For example, in WebMvc.fn:

HandlerFilterFunction<RenderingResponse, RenderingResponse> filter =
        HandlerFilterFunction.ofResponseProcessor((request, response) ->
                RenderingResponse.from(response)
                        .modelAttribute("currentPath", request.path())
                        .build());

If the handler sets a cookie to store a user preference, this filter drops the cookie from the response, so the updated preference is not remembered on subsequent requests.

This PR updates RenderingResponse.from() to copy cookies in both WebMvc.fn and WebFlux.fn, matching the behavior of ServerResponse.from().

Related Issues

Prior to this commit, RenderingResponse.from() did not copy the
cookies of the given response, unlike ServerResponse.from().

See spring-projectsgh-22481

Signed-off-by: Hyunwoo Jung <[email protected]>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 2, 2026
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Oct 2, 2026
@sbrannen sbrannen self-assigned this Oct 2, 2026
@sbrannen sbrannen changed the title Copy cookies in RenderingResponse.from() Copy cookies in RenderingResponse.from() Oct 2, 2026
@sbrannen sbrannen added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 2, 2026
@sbrannen sbrannen added this to the 7.0.10 milestone Oct 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants