title: WebClient doesn't read response until request write is completed.
body: <p>I'm trying to implement streaming proxy.
  I faced with the issue with WebClient from spring reactive.</p>
  
  <p>Could anyone help me to understand Do I some wrong way or it's just a bug from WebClient side?</p>
  
  <p><strong>Stack:</strong></p>
  
  <p><strong>reactor-netty 0.7.8.RELEASE</strong></p>
  
  <p><strong>spring-boot 2.0.4.RELEASE</strong></p>
  
  <p><strong>Desc:</strong></p>
  
  <p>I want to proxy a long stream to external service and then forward stream of responses to the requester.
  Streaming is happening using chunks (HTTP 1.1 Transfer-Encoding : chunked).
  External service processes every chunk and sends to the response result.</p>
  
  <p><strong>Expected behaviour:</strong></p>
  
  <p>WebClient should read every received part of response immediately.</p>
  
  <p><strong>Actual behaviour:</strong></p>
  
  <p>WebClient doesn't start process response until request write is completed.</p>
  
  <p><strong>Code:</strong> </p>
  
  <pre><code>return client
      .post()
      .header("Transfer-Encoding", "chunked")
  //because I want to flush each received part
      .body((outputMessage, context) -&gt; outputMessage.writeAndFlushWith(
          request.body(BodyExtractors.toDataBuffers())
                 .map(dataBuffer -&gt; Mono.just(dataBuffer))))
      .exchange()
      .flatMap(clientResponse -&gt; {
        ServerResponse.BodyBuilder bodyBuilder = ServerResponse.status(clientResponse.statusCode());
        bodyBuilder.contentType(MediaType.APPLICATION_STREAM_JSON);
  
        return bodyBuilder.body((outputMessage, context) -&gt;                                                        
            outputMessage.writeAndFlushWith(                                               
              clientResponse.body(BodyExtractors.toDataBuffers())                                                               
                            .map(dataBuffer -&gt; Mono.just(dataBuffer))
                           ));}
  );
  </code></pre>