Skip to content

JDK Http Client cannot handle compressed http response inputstream #35222

@spicydev

Description

@spicydev

Issue is reproducible when you create new RestClient by adding Accept-Encoding: gzip as default header and try to read response body.

RestClient.builder().baseUrl("https://example.com")
                .defaultHeader("Accept-Encoding", "gzip")
                .requestFactory(new JdkClientHttpRequestFactory())
                .build();

Have you considered asking for help on stackoverflow.com?

Yes. All documentation say that JDK Http Client only handles HTTP2 compressed headers automatically but cannot handle response body compressed using gzip / br / deflate, etc

** Enhancements requests **
We need to enhance JdkClientHttpRequestFactory to add new method similar to read-timeout workaround and create a custom jdk BodyHandler that wraps the decompression logic by using JDK inbuilt GZIPInputStream when response contains Content-Encoding header, etc.

Changes would be needed in JdkClientHttpRequestFactory, JdkHttpClientRequest

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions