Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4095

Unirest doesn't return content-encoding gzip header

$
0
0

I am using Unirest in java app for API call.The API server is a spring-boot app with the compression enabled

server.compression.enabled=trueserver.compression.mime-types=application/jsonserver.compression.min-response-size=1

This is my api call

HttpResponse<String> response = Unirest.post(url)                .header("Accept-Encoding", "gzip")                .header("Content-Type", "application/json")                .body(request)                .asString();

However response header "Content-Type" is always "application/json"

Unirest version

<dependency><groupId>com.konghq</groupId><artifactId>unirest-java</artifactId><version>3.14.5</version></dependency>

I am using it with SSL connection from Spring boot app v.3.3.5.

I tried the same call with curl

curl --request POST --url 'myurl' --header 'Accept-Encoding: gzip' --header 'Content-Type: application/json' --data 'jsonData' -i | less

Response

...HTTP/1.1 200vary: accept-encodingContent-Encoding: gzipContent-Type: application/json ...

I tried the same API call from Insomnia client

> POST ...> User-Agent: insomnia/2021.4.1> Content-Type: application/json> Accept-Encoding: gzip

Response:

< HTTP/1.1 200 < vary: accept-encoding< Content-Encoding: gzip< Content-Type: application/json...

I also checked request headers in APi server and they all have "Accept-Encoding: gzip". It looks like it doesn't work only with Unirest.


Viewing all articles
Browse latest Browse all 4095

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>