5656import org .apache .hc .client5 .http .cookie .CookieSpecFactory ;
5757import org .apache .hc .client5 .http .cookie .CookieStore ;
5858import org .apache .hc .client5 .http .entity .InputStreamFactory ;
59- import org .apache .hc .client5 .http .entity .compress .ContentCodecRegistry ;
60- import org .apache .hc .client5 .http .entity .compress .ContentCoding ;
59+ import org .apache .hc .client5 .http .entity .compress .DecompressingEntity ;
6160import org .apache .hc .client5 .http .impl .ChainElement ;
6261import org .apache .hc .client5 .http .impl .CookieSpecSupport ;
6362import org .apache .hc .client5 .http .impl .DefaultAuthenticationStrategy ;
@@ -215,7 +214,6 @@ private ExecInterceptorEntry(
215214 private BackoffManager backoffManager ;
216215 private Lookup <AuthSchemeFactory > authSchemeRegistry ;
217216 private Lookup <CookieSpecFactory > cookieSpecRegistry ;
218- @ Deprecated
219217 private LinkedHashMap <String , InputStreamFactory > contentDecoderMap ;
220218 private CookieStore cookieStore ;
221219 private CredentialsProvider credentialsProvider ;
@@ -239,12 +237,6 @@ private ExecInterceptorEntry(
239237
240238 private List <Closeable > closeables ;
241239
242- /**
243- * Custom decoders keyed by {@link ContentCoding}.
244- *
245- */
246- private LinkedHashMap <ContentCoding , UnaryOperator <HttpEntity >> contentDecoder ;
247-
248240 public static HttpClientBuilder create () {
249241 return new HttpClientBuilder ();
250242 }
@@ -714,23 +706,6 @@ public final HttpClientBuilder setContentDecoderRegistry(
714706 return this ;
715707 }
716708
717- /**
718- * Sets a map of {@linkplain java.util.function.UnaryOperator}<HttpEntity> decoders,
719- * keyed by {@link ContentCoding}, to be used for automatic response decompression.
720- *
721- * @param contentDecoder decoder map, or {@code null} to fall back to the
722- * defaults from {@link ContentCodecRegistry}.
723- * @return this builder.
724- *
725- * @since 5.6
726- */
727- public final HttpClientBuilder setContentDecoder (
728- final LinkedHashMap <ContentCoding , UnaryOperator <HttpEntity >> contentDecoder ) {
729- this .contentDecoder = contentDecoder ;
730- return this ;
731- }
732-
733-
734709 /**
735710 * Sets default {@link RequestConfig} instance which will be used
736711 * for request execution if not explicitly set in the client execution
@@ -992,13 +967,16 @@ public CloseableHttpClient build() {
992967
993968 if (!contentCompressionDisabled ) {
994969 // Custom decoder map supplied by the caller
995- if (contentDecoder != null ) {
996- final List <String > encodings = new ArrayList <>(contentDecoder .size ());
970+ if (contentDecoderMap != null ) {
971+ final List <String > encodings = new ArrayList <>(contentDecoderMap .size ());
997972 final RegistryBuilder <UnaryOperator <HttpEntity >> b2 = RegistryBuilder .create ();
998- for (final Map .Entry <ContentCoding , UnaryOperator <HttpEntity >> entry : contentDecoder .entrySet ()) {
999- final String token = entry .getKey ().token ();
973+ for (final Map .Entry <String , InputStreamFactory > entry : contentDecoderMap .entrySet ()) {
974+ final String token = entry .getKey ();
975+ final InputStreamFactory inputStreamFactory = entry .getValue ();
1000976 encodings .add (token );
1001- b2 .register (token , entry .getValue ());
977+ b2 .register (token , httpEntity -> new DecompressingEntity (
978+ httpEntity ,
979+ inputStreamFactory ::create ));
1002980 }
1003981 final Registry <UnaryOperator <HttpEntity >> decoderRegistry = b2 .build ();
1004982
0 commit comments