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

POST empty body no longer sending content-length 0 #3660

Open
bachah opened this issue Feb 28, 2025 · 0 comments
Open

POST empty body no longer sending content-length 0 #3660

bachah opened this issue Feb 28, 2025 · 0 comments
Labels
status/need-triage A new issue that still need to be evaluated as a whole type/bug A general bug

Comments

@bachah
Copy link

bachah commented Feb 28, 2025

Hello,

As a potential side-effect of this change: #3603 , when sending a POST with no body, the content-length: 0 is no longer there.

Sample code:

`
public static void main(String[] args) {
DisposableServer server = HttpServer.create().host("localhost").handle((request, response) -> {
request.requestHeaders().forEach(header -> System.out.println(header.getKey() + ": " + header.getValue()));
return response.status(200).send();
}).bindNow();
WebClient.builder()
.build()
.method(POST)
.uri("http://"+server.host() + ":" + server.port())
.retrieve().bodyToMono(Void.class).block();
}

`

Using the default webClient config, the behaviour back in 1.0.39 was the following:

accept-encoding: gzip
user-agent: ReactorNetty/1.0.39
host: 127.0.0.1:55767
accept: /
transfer-encoding: chunked

Then in 1.2.2:

accept-encoding: gzip
user-agent: ReactorNetty/1.2.2
host: 127.0.0.1:56881
accept: /
content-length: 0

And now in 1.2.3:
accept-encoding: gzip
user-agent: ReactorNetty/1.2.3
host: 127.0.0.1:56837
accept: /

Some servers require either 'transfer-encoding: chunked' or 'content-length', but since there's no body in the POST, the correct recommended behaviour is to send a content-length: 0, I would like to know why it was removed knowing that the referenced issue only references 'GET' requests which is understandable since it's not recommended to have a body, but why impact the POST flow? https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2

Kindly advise.
Thank you.

@bachah bachah added status/need-triage A new issue that still need to be evaluated as a whole type/bug A general bug labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/need-triage A new issue that still need to be evaluated as a whole type/bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant