title: How to get ClientResponse body as DataBuffer in WebClient.exchangeToMono Spring 5.3?
body: <p>Before the deprecation of <code>WebClient.exchange</code> method I used to get ClientResponse body as <code>Flux&lt;DataBuffer&gt;</code> and manipulated it.</p>
  <p>In Spring 5.3 the <code>exchange()</code> method is deprecated and I would like to change the implementation as recommended:</p>
  <blockquote>
  <p>@deprecated since 5.3 due to the possibility to leak memory and/or
  connections; please,
  use {@link #exchangeToMono(Function)}, {@link #exchangeToFlux(Function)};
  consider also using {@link #retrieve()} ...</p>
  </blockquote>
  <p>Tried to do the same call in the lambda passed to <code>exchangeToMono</code>, but <code>clientResponse.bodyToFlux(DataBuffer::class.java)</code> always return an empty flux; other experiments (i.e. getting body as mono string) also could not help to get the body.</p>
  <p><strong>What is the standard way to get the ClientResponse body in Spring 5.3 ?</strong></p>
  <p><em>I am looking for a low-level body representation: something like &quot;data buffer&quot;, &quot;byte array&quot; or &quot;input stream&quot;; to avoid any kind of parsing/deserialisation.</em></p>
  <p><strong>Before Spring 5.3:</strong></p>
  <pre><code>webClient
      .method(GET)
      .uri(&quot;http://somewhere.com&quot;)
      .exchange()
      .flatMap { clientResponse -&gt;
         val bodyRaw: Flux&lt;DataBuffer&gt; = clientResponse.bodyToFlux(DataBuffer::class.java) 
         // ^ body as expected
             
         // other operations
      }
  </code></pre>
  <p><strong>After Spring 5.3</strong></p>
  <pre><code>webClient
      .method(GET)
      .uri(&quot;http://somewhere.com&quot;)
      .exchangeToMono { clientResponse -&gt;
         val bodyRaw: Flux&lt;DataBuffer&gt; = clientResponse.bodyToFlux(DataBuffer::class.java)
         // ^ always empty flux
             
         // other operations
      }
  </code></pre>