In recent versions of OkHttp library, headers like "Accept-Encoding" and "User-Agent" are added automatically if you don't provide them by yourself.
Is there a way to disable this feature?
Strip 'em with a Network Interceptor.
client.networkInterceptors().add(new Interceptor() {
@Override public Response intercept(Chain chain) throws IOException {
Request request = chain.request()
.newBuilder()
.removeHeader("Accept-Encoding")
.removeHeader("User-Agent")
.build();
return chain.proceed(request);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With