Skip to content

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

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

Closed
spring-projects-issues opened this issue Jun 18, 2018 · 7 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues 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:

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

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues 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-projects-issues
Copy link
Collaborator Author

spring-projects-issues 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-projects-issues
Copy link
Collaborator Author

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-projects-issues
Copy link
Collaborator Author

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-projects-issues
Copy link
Collaborator Author

Mirko Adebahr commented

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

@spring-projects-issues
Copy link
Collaborator Author

Mirko Adebahr commented

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

@spring-projects-issues
Copy link
Collaborator Author

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
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants