Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.61k stars 594 forks source link

ACCEPT_ENCODING_HEADER can't be removed #129

Closed m-emelchenkov closed 5 years ago

m-emelchenkov commented 8 years ago

It's necessary to have an ability to remove ACCEPT_ENCODING_HEADER from request headers. If it is not set then it set its default value which is not acceptable for my use-case, where there should not be this header at all.

m-emelchenkov commented 8 years ago

It's necessary to remove the code from unirest-java which adds the ACCEPT_ENCODING_HEADER and also call something like CloseableHttpClient client = HttpClientBuilder.create().disableContentCompression().build(), or this header will be added by Apache framework.

shashiranjan84 commented 8 years ago

You can set custom HttpClient object with desired configuration in Unirest.setHttpClient public interface.

m-emelchenkov commented 8 years ago

Hi! I don't think so because you have the code in HttpClientHelper.java in function prepareRequest():

        if (!request.getHeaders().containsKey(ACCEPT_ENCODING_HEADER)) {
            request.header(ACCEPT_ENCODING_HEADER, "gzip");
        }

It is always called, even for custom HttpClient, isn't it? Please excuse me if I wrong.

shashiranjan84 commented 8 years ago

Sorry I should have checked. Reopening the issue But expect delayed resolution. Feel free to contribute to project with a PR :)

CoryKniefel commented 5 years ago

What the? Really? This is a blocker for me and I've wasted 3 hours on this library.

ryber commented 5 years ago

i've exposed a config option to turn off default compression. should get released later today