Ovidiu Latcu
Ovidiu Latcu

Reputation: 72311

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.

Upvotes: 3

Views: 1240

Answers (3)

Jim Ferrans
Jim Ferrans

Reputation: 31012

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.

Upvotes: 5

Alex Objelean
Alex Objelean

Reputation: 4133

You could try to change the Accept-Encoding header, by removing the gzip|deflate value. If this doesn't work, you should also take into account that server doesn't care if the client supports the gzipped content (which is a bug and should be fixed).

Upvotes: 1

Maurício Linhares
Maurício Linhares

Reputation: 40333

You should set the Accept-Encoding header to identity.

Upvotes: 1

Related Questions