Skip to content

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

Closed

Description

@spring-projects-issues

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

Activity

  1. spring-projects-issues commented on Jun 18, 2018

    @spring-projects-issues
    CollaboratorAuthor

    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,

  2. spring-projects-issues commented on Jun 18, 2018

    @spring-projects-issues
    CollaboratorAuthor

    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?

  3. spring-projects-issues commented on Jun 19, 2018

    @spring-projects-issues
    CollaboratorAuthor

    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!

  4. spring-projects-issues commented on Jul 2, 2018

    @spring-projects-issues
    CollaboratorAuthor

    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...

  5. spring-projects-issues commented on Jul 2, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Mirko Adebahr commented

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

  6. spring-projects-issues commented on Jul 4, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Mirko Adebahr commented

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

  7. spring-projects-issues commented on Jul 4, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

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

  8. added
    type: enhancement
    in: web
    on Jan 11, 2019
  9. added this to the 5.0.8 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions