title: How to override any HttpHeader in response of WebClient?
body: <pre><code>WebClient.builder().baseUrl("/").filter(contentTypeInterceptor()).build();
  </code></pre>
  
  <p>How can I modify the <code>Content-Type</code> of the received response (because I'm receiving a response from a webserver that emits the wrong content type. As I'm not in control of the external server, I'd like to correct the content type for further correct processing (eg with jackson library etc).</p>
  
  <pre><code>private ExchangeFilterFunction contentTypeInterceptor() {
      return ExchangeFilterFunction.ofResponseProcessor(clientResponse -&gt; {
          org.springframework.web.reactive.function.client.ClientResponse.Headers headers = clientResponse.headers();
          //TODO how to headers.setContentType("myval) or headers.set("Content-Type", "myval");   
          //headers.asHttpHeaders(); cannot be used as it is readonly
      });
  }
  </code></pre>
  
  <p>The question could be answered in general how to override any http header.</p>
  
  <p>The root cause in my case is that I receive <code>text/html</code>, but the response body is actually a <code>application/xml</code>. And <code>jackson</code> rejects parsing that response due to:</p>
  
  <p><code>org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'text/html' not supported for bodyType=MyResponse</code></p>