Hi! When a REST endpoint returns Status code 303 with Location header, we'd expect that WebClient will call the new endpoint(Found in the Location header) with the GET method as Suggested here. But WebClient is calling the new API with the original HttpMethod.

Post to this API will return the new location with 303 Status.

    @PostMapping("/post-existing")
    fun test(@RequestBody modelMap: ModelMap): ResponseEntity<ModelMap> {
        val responseHeaders = HttpHeaders()
        responseHeaders["Location"] = "http://localhost:8090/api2/resource/123"
        return ResponseEntity.status(HttpStatus.SEE_OTHER).headers(responseHeaders).build()
    }

This API will return the new resource when called using GET method

    @GetMapping("/resource/${id}")
    fun returnSome(@PathVariable id: String): ResponseEntity<ModelMap> {
        return ResponseEntity.ok(ModelMap("message", "success"))
    }

When call is made to the POST /post-existing, we are expecting WebClient to make the GET /resource/123 call but instead it is making POST /resource/123 call.

This is my WebClient config.

WebClient.builder()
            .clientConnector(ReactorClientHttpConnector(
                HttpClient.create()
                    .followRedirect { _, res ->
                        log.debug("Redirect Location " + res.responseHeaders().get("Location"))
                        true
                    }
                    .wiretap(HttpClient::class.java.canonicalName, LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL)))
            .build
  • Spring Boot Version 2.6.8
  • Spring WebFlux Version 5.3.20

Comment From: bclozel

This is using the Reactor Netty ˋHttpClient` API directly so I don't think this behavior is implemented in Spring Boot nor Spring Framework.

Could you open this issue against the Reactor Netty project please?