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

Netty 4 Does Not Send Request Body #823

Open
lukasniemeier-zalando opened this issue Nov 16, 2019 · 6 comments
Open

Netty 4 Does Not Send Request Body #823

lukasniemeier-zalando opened this issue Nov 16, 2019 · 6 comments
Labels
Milestone

Comments

@lukasniemeier-zalando
Copy link
Member

When using Netty4ClientHttpRequestFactory request bodies are not send to the server.

Expected Behavior

Request body is transmitted.

Actual Behavior

Server observes empty request body.

Steps to Reproduce

See a85ce45.

Your Environment

@lukasniemeier-zalando
Copy link
Member Author

Curiously request bodies are send/flushed when calling close on the body stream, like it's proposed for the request compression plugin in

try (final WrappingHttpOutputMessage compressingMessage =
new WrappingHttpOutputMessage(message, compression.getOutputStreamDecorator())) {
entity.writeTo(compressingMessage);
}
.

@whiskeysierra
Copy link
Collaborator

Might be related to spring-projects/spring-framework#19426

@whiskeysierra
Copy link
Collaborator

If I enable the factory in the request compression test it fails in mysterious ways:

Spring 4.x

  • ✔️ shouldCompressWithGivenAlgorithm
  • ✔️ shouldCompressRequestBody
  • shouldBackOffIfAlreadyEncoded
  • ✔️ shouldNotCompressEmptyRequestBody

Spring 5.x

  • shouldCompressWithGivenAlgorithm
  • shouldCompressRequestBody
  • ✔️ shouldBackOffIfAlreadyEncoded
  • ✔️ shouldNotCompressEmptyRequestBody

@whiskeysierra
Copy link
Collaborator

whiskeysierra commented Nov 21, 2019

The following was added in between 4.x and 5.x within the Netty4ClientHttpRequest and fixes the issue in Spring 4.x:

if (!nettyRequest.headers().contains(HttpHeaders.CONTENT_LENGTH) && this.body.buffer().readableBytes() > 0) {
	nettyRequest.headers().set(HttpHeaders.CONTENT_LENGTH, this.body.buffer().readableBytes());
}

Since that seems to be an issue in Spring I'd say it's not our task to fix. The issues in 5.x could be related to our compression and headers though. My idea was that we set the wrong content length and somehow the whole request is not send. But I can't prove that using the debugger.

@lukasniemeier-zalando
Copy link
Member Author

The following was added in between 4.x and 5.x within the Netty4ClientHttpRequest and fixes the issue in Spring 4.x

Which is funny, see #822 (comment)

@whiskeysierra whiskeysierra added this to the 3.0.0 milestone Dec 18, 2019
@whiskeysierra
Copy link
Collaborator

@whiskeysierra whiskeysierra pinned this issue Feb 18, 2020
@whiskeysierra whiskeysierra modified the milestones: 3.0.0, 4.0.0 Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants