How to decompress gzip response body using Spring RestClient?

265 Views Asked by At

The oficial docs don't mention how to configure RestClient to decompress a gzip response. By default it doesn't seem to decompress it like WebClient does.

1

There are 1 best solutions below

0
Ignasi On BEST ANSWER

It can be done by adding io.projectreactor.netty:reactor-netty:1.1.15 dependency and using ReactorNettyClientRequestFactory as a request factory:

RestClient.builder()
                .requestFactory(new ReactorNettyClientRequestFactory())
                .build()
                .get()
                .uri(uri)
                .retrieve()
                .body(String.class);

Then gzip decompression is done automatically.