56
56
import org .apache .hc .client5 .http .cookie .CookieSpecFactory ;
57
57
import org .apache .hc .client5 .http .cookie .CookieStore ;
58
58
import 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 ;
61
60
import org .apache .hc .client5 .http .impl .ChainElement ;
62
61
import org .apache .hc .client5 .http .impl .CookieSpecSupport ;
63
62
import org .apache .hc .client5 .http .impl .DefaultAuthenticationStrategy ;
@@ -215,7 +214,6 @@ private ExecInterceptorEntry(
215
214
private BackoffManager backoffManager ;
216
215
private Lookup <AuthSchemeFactory > authSchemeRegistry ;
217
216
private Lookup <CookieSpecFactory > cookieSpecRegistry ;
218
- @ Deprecated
219
217
private LinkedHashMap <String , InputStreamFactory > contentDecoderMap ;
220
218
private CookieStore cookieStore ;
221
219
private CredentialsProvider credentialsProvider ;
@@ -239,12 +237,6 @@ private ExecInterceptorEntry(
239
237
240
238
private List <Closeable > closeables ;
241
239
242
- /**
243
- * Custom decoders keyed by {@link ContentCoding}.
244
- *
245
- */
246
- private LinkedHashMap <ContentCoding , UnaryOperator <HttpEntity >> contentDecoder ;
247
-
248
240
public static HttpClientBuilder create () {
249
241
return new HttpClientBuilder ();
250
242
}
@@ -714,23 +706,6 @@ public final HttpClientBuilder setContentDecoderRegistry(
714
706
return this ;
715
707
}
716
708
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
-
734
709
/**
735
710
* Sets default {@link RequestConfig} instance which will be used
736
711
* for request execution if not explicitly set in the client execution
@@ -992,13 +967,16 @@ public CloseableHttpClient build() {
992
967
993
968
if (!contentCompressionDisabled ) {
994
969
// 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 ());
997
972
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 ();
1000
976
encodings .add (token );
1001
- b2 .register (token , entry .getValue ());
977
+ b2 .register (token , httpEntity -> new DecompressingEntity (
978
+ httpEntity ,
979
+ inputStreamFactory ::create ));
1002
980
}
1003
981
final Registry <UnaryOperator <HttpEntity >> decoderRegistry = b2 .build ();
1004
982
0 commit comments