Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenderingResponse does not set status code on redirect views #28839

Closed
tgrushka opened this issue Jul 18, 2022 · 0 comments
Closed

RenderingResponse does not set status code on redirect views #28839

tgrushka opened this issue Jul 18, 2022 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@tgrushka
Copy link

Version: org.springframework:spring-webflux:5.3.21

Problem: When I use RenderingResponse.create("redirect:/controller").status(HttpStatus.FOUND).build(), the response status is not modified (remains 303 See Other no matter what).

(.status(something) works fine on a non-redirect view: RenderingResponse.create("template").status(something).build().)

Expected Behavior: When I modify the status of a "redirect view", I expect the status to be as directed in the invocation.

Actual Behavior: The redirect works fine. However, its status is 303 See Other no matter what I set it to.

I have a router:

@Configuration
class CVRouter(private val controller: CVController) {
    @Bean
    fun route() = router {
        path("/cvs").nest {
            GET("", controller::list)
            GET("new", controller::new)
            POST("", controller::create)
        }
    }
}

and a controller:

@Component
class CVController(val repository: CVRepository) {
    fun list(request: ServerRequest) = RenderingResponse
        .create("cv/list")
        .modelAttribute("cvs", repository.findAll())
        .build()

    fun new(request: ServerRequest) = RenderingResponse
        .create("cv/new")
        .modelAttribute("cv", CV(name = "Test Name"))
        .build()

    // This does not create anything yet, only testing PRG (Post/Redirect/Get) pattern.
    fun create(request: ServerRequest) = RenderingResponse
        .create("redirect:/cvs")
        .status(HttpStatus.FOUND)
        .build()
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 18, 2022
@poutsma poutsma self-assigned this Jul 25, 2022
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jul 27, 2022
@rstoyanchev rstoyanchev added this to the Triage Queue milestone Aug 1, 2022
@poutsma poutsma added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 30, 2022
@poutsma poutsma modified the milestones: Triage Queue, 5.3.23 Aug 30, 2022
@poutsma poutsma changed the title .status(HttpStatus) ignored on RenderingResponse.create("redirect:/somewhere").status(...) RenderingResponse does not set status code on redirect views Aug 30, 2022
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

No branches or pull requests

5 participants