I am doing some testing with Spring WebClient. In the following codes, I have set the compress to true. However when I check the debug logs, I can see the "accept-encoding: gzip" header is added, but the body is not compressed. Any way to force compress on post request body? Thanks.
HttpClient httpClient = HttpClient.create().compress(true).wiretap(true);
WebClient webClient = WebClient.builder()
.baseUrl("https://jsonplaceholder.typicode.com")
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.clientConnector(new ReactorClientHttpConnector(httpClient))
.build();
Post post = new Post();
post.setUserId(1000L);
post.setId(2000L);
post.setTitle("Reactor Netty");
StringBuffer sb = new StringBuffer();
IntStream.range(1, 1000).forEach(i -> sb.append("Spring boot webclient"));
post.setBody(sb.toString());
Post p = webClient.post().uri("/posts").syncBody(post).retrieve().bodyToMono(Post.class).block();