0
votes
httpClient.post().uri(getSearchUrl())
                    .send(Mono.just(Unpooled.wrappedBuffer(bytes)))
                    .responseSingle((resp, buf) -> {
                        return buf;
                    })
                    .map(ByteBuf::retain)
                    .map(byteBuf -> {
                        response.setResponseBodyStream(new ByteBufInputStream(byteBuf, true));
                        return response;
                    });

In the method responseSingle,the respone is already uncompressed. So how can I get the length of compressed response? Thanks.

1

1 Answers

1
votes

Check the response headers. You probably have the header "Content-Length" that should tell you the response size.

Otherwise, you can get the body as a ByteArrayResource and check the size of the array of bytes.

.exchange()
.flatMap(clientResponse -> clientResponse.bodyToMono(ByteArrayResource.class)
     .flatMap(responseBodyByteArray -> checkSize(responseBodyByteArray.getByteArray().length))
 )