Unable to Set Status on RedirectView
in Rendering.Builder
#33497
Labels
status: superseded
An issue that has been superseded by another
Issue: Unable to Set Status on
RedirectView
inRendering.Builder
Description
In the current implementation of the
Rendering.Builder
in Spring WebFlux, it is not possible to set the status code on theRedirectView
when using theredirectTo
method. This limitation makes thestatus
method on theRendering.Builder
ineffective for redirects, as the status code is not propagated to theRedirectView
.Steps to Reproduce
Mono<Rendering>
.Rendering.redirectTo("url").status(HttpStatus.NOT_FOUND).build()
method to create a redirect response.RedirectView
is not set toHttpStatus.NOT_FOUND
.Expected Behavior
The status code set on the
Rendering.Builder
should be propagated to theRedirectView
, ensuring that the redirect response has the correct status code.Actual Behavior
The status code is only set on the
Rendering
object and not on theRedirectView
, resulting in the default status code being used for the redirect.Proposed Solution
Modify the
DefaultRenderingBuilder
class to set the status code on theRedirectView
when thestatus
method is called. Here is the proposed change:With this change, the status code set on the
Rendering.Builder
will also be applied to theRedirectView
.Environment
Additional Context
This issue affects any application using Spring WebFlux that relies on setting custom status codes for redirects. The proposed solution ensures consistency and correctness in the HTTP response status for redirects.
The text was updated successfully, but these errors were encountered: