
com.marklogic.client.extra.okhttpclient.RemoveAcceptEncodingConfigurator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marklogic-client-api Show documentation
Show all versions of marklogic-client-api Show documentation
The official MarkLogic Java client API.
The newest version!
package com.marklogic.client.extra.okhttpclient;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/**
* Can be used with {@code DatabaseClientFactory.addConfigurator} to remove the "Accept-Encoding=gzip" request header
* that the underlying OkHttp library adds by default. This is useful in a scenario where many small HTTP responses
* are expected to be returned by MarkLogic, and thus the costs of gzipping the responses may outweigh the benefits.
*
* @since 6.3.0
*/
public class RemoveAcceptEncodingConfigurator implements OkHttpClientConfigurator {
@Override
public void configure(OkHttpClient.Builder builder) {
builder.addNetworkInterceptor(chain -> {
Request newRequest = chain.request().newBuilder().removeHeader("Accept-Encoding").build();
return chain.proceed(newRequest);
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy