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

Content-Length should be set in the request when using reactive WebClient [SPR-16949] #19562

Closed
spring-issuemaster opened this issue Jun 18, 2018 · 7 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jun 18, 2018

Mirko Adebahr opened SPR-16949 and commented

As of #21431, the content-length header should be set in the request for Mono publishers when using the reactive WebClient. Still, as far as I can see the header is not set in the HTTP request.

This is what I think is the problem:

  1. AbstractClientHttpRequest::doCommit: applyHeaders() is called as commit action -> Headers are applied to httpRequest in ReactorClientHttpRequest
  2. After this, body.doOnNext(data -> headers.setContentLength(data.readableByteCount())) is called (see EncoderHttpMessageWriter::write)

The doOnNext seems to be executed too late to have an effect on the headers in the HTTP request.


Affects: 5.0.7

Issue Links:

  • #21431 AbstractJackson2Encoder::getContentLength should not return null for MonoJust/FluxJust publisher

Referenced from: commits 280da61, 6189e17, 4a26f93, d1c9401

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 18, 2018

Brian Clozel commented

Hi Mirko Adebahr,

As of #21431, we've got integration tests covering this use case (see the changes attached to the commit fixing that issue).

Could you provide us with a small application that reproduces this issue?

Thanks,

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 18, 2018

Mirko Adebahr commented

Hi Brian,

please correct me if I'm wrong, but if you're referring to RequestMappingMessageConversionIntegrationTests, as far as I can see all tests check the content-length header on the HTTP response. #21431 as well as the present issue was/is about the header not being set in the outgoing HTTP request.

I understand that an application for reproduction of this issue would be helpful, but we're talking about a client/server scenario. Maybe it would be sufficient if someone familiar with webflux could take a look and confirm the problem?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 19, 2018

Brian Clozel commented

Mirko Adebahr,

This is now fixed in 5.0.x and master (5.1.x) - new SNAPSHOT builds should be available shortly if you'd like to test it against your project before the next releases.

Thanks!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 2, 2018

Juergen Hoeller commented

Mirko Adebahr, please give this a try against a recent snapshot: ideally 5.0.8.BUILD-SNAPSHOT, available via Maven from https://repo.spring.io/snapshot... We'll release 5.0.8 in about three weeks, and it'd be great to know upfront whether it works for you now...

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 2, 2018

Mirko Adebahr commented

OK, I'll try to test it until Wednesday.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 4, 2018

Mirko Adebahr commented

It's working, we're looking forward for the next release. Thanks!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jul 4, 2018

Brian Clozel commented

Thanks a lot for checking Mirko Adebahr, this is helping a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.