0
votes
public VertxHttpClient(Vertx vertx) {
    this(vertx, new WebClientOptions().setTryUseCompression(true));
}

when I add accept-encoding header to the request.

kernelHttpRequest.setHeader("Accept-Encoding", "gzip");

The Vert.x-WebClient/3.9.5 ignores this header and The response which i receive from server does not have "content-encoding" header option.

Rather it have header as "Transfer-Encoding": "chunked".

"headers": {
        "Transfer-Encoding": [
            "chunked"
        ],

How can i pass accept-encoding = gzip and decompress the response which i am getting from server with Vert.x-WebClient/3.9.5

1
Are you sure the client is not setting this header? Have you verified with a network capture tool? Maybe it's the server that is ignoring it - geoand
If I remove setTryUseCompression(true) and add explicit accept-encoding header as gzip, I get the response header as content-encoding. But then web client is not able to decompress the response by default. - mayur_mitkari

1 Answers

0
votes

you should create the client with the appropriate option independantly of chunking:

client = vertx.createHttpClient(createBaseClientOptions().setTryUseCompression(true));

The setTryUseCompression actually tell the client to set an accept-encoding header to gzip and will decompress the response when the server has set the content-encoding header to gzip.

This is explained in the documentation https://vertx.io/docs/vertx-core/java/#_enabling_compression_on_the_client