Right way to remove Gzip encoding in the client

Trying to debug a request with Gzip-encoding turned on is kind of painful, how can I disable this header in the client?

Which Client are you using?

2019-09-23 15:54:53.793 DEBUG 18652 — [ Test worker] org.apache.http.wire : http-outgoing-0 >> “User-Agent: HAPI-FHIR/3.8.0 (FHIR Client; FHIR 4.0.0/R4; apache)[\r][\n]”

I should probably say, that my goal is just to be able to read the actual body content, maybe there’s some way to make apache http client decode it before logging the response.

I’ve tried this, but it didn’t work, I thought this was coming from a default, but either it’s being overridden somewhere, or it’s not just a default

    open fun httpClient(): CloseableHttpClient {
        //FIXME potential resoource leak
        val connectionManager = PoolingHttpClientConnectionManager(

        val defaultRequestConfig = RequestConfig.custom()

        val builder = HttpClients.custom().setConnectionManager(connectionManager)

        return builder.disableContentCompression() .build()

    @ConditionalOnProperty(name = ["site.fhir.endpoint"])
    open fun client2( client: CloseableHttpClient ): IGenericClient {
        val rcf = FhirContext(fhir?.version).restfulClientFactory
        return rcf.newGenericClient(fhir?.endpoint)

this works, I verified disableContentCompression() was working, but the header was still added, I’m not sure where I had to use the interceptor to actually remove it, this feels wrong, I would like to know where it’s being added, it feels like HAPI must be adding it again somewhere, if so I’d like to see a feature to disable it.

    val builder = HttpClients.custom()
        .addInterceptorLast(HttpRequestInterceptor { request, _ ->

If your aim here is just to see the payload over the wire, consider registering the LoggingInterceptor against the client, e.g.

client.registerInterceptor(new LoggingInterceptor(true));

This happens at the application layer so it logs the uncompressed contents.