I am using ExchangeFilterFunction.ofResponseProcessor method to transform the Response received by the WebClient. 1. Add new Headers to response 2. Modify the response Body
ExchangeFilterFunction.ofResponseProcessor(clientResponse ->
Mono.just(
clientResponse
.mutate()
.body("This got modified")
.header("example-header", "EXAMPLE-HEADER")
.build())
);
I am triggering the WebClient through a Postman Call and That will call.
WebClient webClient = WebClient.builder()
.filter(WebClientFilters.modifyResponseHeaders())
.clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
return webClient.get()
.uri("http://localhost:8080/hello-annotated")
.retrieve()
.bodyToMono(String.class);
But When I see the Response Headers received back at Postman I can't see the newly added Headers via the Filter Function.
But I can clearly see the Response Body has Transformed as expected. What is causing the issue for custom headers not getting propagated back to client?
Comment From: bclozel
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.