quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.53k stars 2.61k forks source link

REST client doesn't send body in redirect request #41751

Open jdussouillez opened 1 month ago

jdussouillez commented 1 month ago

Describe the bug

REST client doesn't send the body in the redirect request after a 307 redirect from a POST request. It happens both with RedirectHandler and the new AdvancedRedirectHandler.

The RFC says nothing about the body, however it seems the body should be sent again in the redirect request.

https://developer.mozilla.org/fr/docs/Web/HTTP/Status/307

The method and the body of the original request are reused to perform the redirected request. [...] The only difference between 307 and 302 is that 307 guarantees that the method and the body will not be changed when the redirected request is made.

https://http.dev/307

The 307 Temporary Redirect status code works the same way that the 302 Found status code does, except that 307 Temporary Redirect status code specifically guarantees that the HTTP method and message body will not be changed in the follow-up HTTP request.

Expected behavior

REST client send the original request body in the redirect request after a 307 response.

Actual behavior

REST client doesn't the original request body in the redirect request after a 307 response.

How to Reproduce?

Reproducer: https://github.com/jdussouillez/quarkus-rest-client-post-redirect-post/tree/quarkus-v3.13

Using curl it works fine as the body is transferred to the redirect request.

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.12.1 + current main branch (7e98e77)

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

This issue was first reported on another issue: https://github.com/quarkusio/quarkus/issues/35126#issuecomment-2213814084

quarkus-bot[bot] commented 1 month ago

/cc @cescoffier (rest-client), @geoand (rest-client)

geoand commented 1 month ago

Interesting. This will take some investigating

geoand commented 1 month ago

@vietj when using io.vertx.core.http.HttpClientBuilder#withRedirectHandler isn't the original body supposed to be included?