diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/InputStreamFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/InputStreamFactory.java index a7b8ce43bd..f9adda3f74 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/InputStreamFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/InputStreamFactory.java @@ -31,10 +31,9 @@ /** * Factory for decorated {@link InputStream}s. - * @deprecated Replaced by {@link org.apache.hc.client5.http.entity.compress.Decoder}. * @since 4.4 */ -@Deprecated +@FunctionalInterface public interface InputStreamFactory { InputStream create(InputStream inputStream) throws IOException; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java index d3c8b05edd..a9483d6132 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java @@ -56,8 +56,7 @@ import org.apache.hc.client5.http.cookie.CookieSpecFactory; import org.apache.hc.client5.http.cookie.CookieStore; import org.apache.hc.client5.http.entity.InputStreamFactory; -import org.apache.hc.client5.http.entity.compress.ContentCodecRegistry; -import org.apache.hc.client5.http.entity.compress.ContentCoding; +import org.apache.hc.client5.http.entity.compress.DecompressingEntity; import org.apache.hc.client5.http.impl.ChainElement; import org.apache.hc.client5.http.impl.CookieSpecSupport; import org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy; @@ -215,7 +214,6 @@ private ExecInterceptorEntry( private BackoffManager backoffManager; private Lookup authSchemeRegistry; private Lookup cookieSpecRegistry; - @Deprecated private LinkedHashMap contentDecoderMap; private CookieStore cookieStore; private CredentialsProvider credentialsProvider; @@ -239,12 +237,6 @@ private ExecInterceptorEntry( private List closeables; - /** - * Custom decoders keyed by {@link ContentCoding}. - * - */ - private LinkedHashMap> contentDecoder; - public static HttpClientBuilder create() { return new HttpClientBuilder(); } @@ -714,23 +706,6 @@ public final HttpClientBuilder setContentDecoderRegistry( return this; } - /** - * Sets a map of {@linkplain java.util.function.UnaryOperator}<HttpEntity> decoders, - * keyed by {@link ContentCoding}, to be used for automatic response decompression. - * - * @param contentDecoder decoder map, or {@code null} to fall back to the - * defaults from {@link ContentCodecRegistry}. - * @return this builder. - * - * @since 5.6 - */ - public final HttpClientBuilder setContentDecoder( - final LinkedHashMap> contentDecoder) { - this.contentDecoder = contentDecoder; - return this; - } - - /** * Sets default {@link RequestConfig} instance which will be used * for request execution if not explicitly set in the client execution @@ -992,13 +967,16 @@ public CloseableHttpClient build() { if (!contentCompressionDisabled) { // Custom decoder map supplied by the caller - if (contentDecoder != null) { - final List encodings = new ArrayList<>(contentDecoder.size()); + if (contentDecoderMap != null) { + final List encodings = new ArrayList<>(contentDecoderMap.size()); final RegistryBuilder> b2 = RegistryBuilder.create(); - for (final Map.Entry> entry : contentDecoder.entrySet()) { - final String token = entry.getKey().token(); + for (final Map.Entry entry : contentDecoderMap.entrySet()) { + final String token = entry.getKey(); + final InputStreamFactory inputStreamFactory = entry.getValue(); encodings.add(token); - b2.register(token, entry.getValue()); + b2.register(token, httpEntity -> new DecompressingEntity( + httpEntity, + inputStreamFactory::create)); } final Registry> decoderRegistry = b2.build();