Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java HttpGet doesn't accept gzip

I am making an HttpGet to an url and I do not want the server to send the data gzipped. What header should I include in my HttpGet ?

With the default headers, the server sends gzipped data from time to time. I don't want this to happen. Thanks.

like image 700
Ovidiu Latcu Avatar asked Apr 09 '26 07:04

Ovidiu Latcu


2 Answers

You want the Accept-Encoding HTTP request header.

Update: per @Selvin's comment, leave it empty or set it to "identity".

Update: The web application has to cooperate properly to be HTTP compliant, of course. If it's not honoring Accept-Encoding, look at its Content-Encoding HTTP response header. If it's "gzip", just read the response body with Java's GZIPInputStream.html. Then add "gzip" to your Accept-Encoding request header, since your client now handles GZIP. If the web application doesn't set the Content-Encoding header properly, that's another story altogether.

like image 85
Jim Ferrans Avatar answered Apr 11 '26 20:04

Jim Ferrans


You should set the Accept-Encoding header to identity.

like image 37
Maurício Linhares Avatar answered Apr 11 '26 22:04

Maurício Linhares



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!