Skip to content

Copy cookies in RenderingResponse.from() - #37378

Merged
sbrannen merged 1 commit into
spring-projects:7.0.xfrom
noojung:rendering-response-from-cookies
Oct 3, 2026
Merged

sbrannen merged 1 commit into
spring-projects:7.0.xfrom
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

@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
Prior to this commit, RenderingResponse.from() did not copy the
cookies of the given response, unlike ServerResponse.from().

See spring-projectsgh-22481
Closes spring-projectsgh-37378

Signed-off-by: Hyunwoo Jung <hyunwoojung@kakao.com>
@sbrannen
sbrannen force-pushed the rendering-response-from-cookies branch from 2125ee0 to 647acec Compare October 3, 2026 12:13
@sbrannen
sbrannen changed the base branch from main to 7.0.x October 3, 2026 12:13
@sbrannen
sbrannen merged commit f03b76a into spring-projects:7.0.x Oct 3, 2026
1 of 2 checks passed
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