Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -215,7 +214,6 @@ private ExecInterceptorEntry(
private BackoffManager backoffManager;
private Lookup<AuthSchemeFactory> authSchemeRegistry;
private Lookup<CookieSpecFactory> cookieSpecRegistry;
@Deprecated
private LinkedHashMap<String, InputStreamFactory> contentDecoderMap;
private CookieStore cookieStore;
private CredentialsProvider credentialsProvider;
Expand All @@ -239,12 +237,6 @@ private ExecInterceptorEntry(

private List<Closeable> closeables;

/**
* Custom decoders keyed by {@link ContentCoding}.
*
*/
private LinkedHashMap<ContentCoding, UnaryOperator<HttpEntity>> contentDecoder;

public static HttpClientBuilder create() {
return new HttpClientBuilder();
}
Expand Down Expand Up @@ -714,23 +706,6 @@ public final HttpClientBuilder setContentDecoderRegistry(
return this;
}

/**
* Sets a map of {@linkplain java.util.function.UnaryOperator}&lt;HttpEntity&gt; 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<ContentCoding, UnaryOperator<HttpEntity>> 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
Expand Down Expand Up @@ -992,13 +967,16 @@ public CloseableHttpClient build() {

if (!contentCompressionDisabled) {
// Custom decoder map supplied by the caller
if (contentDecoder != null) {
final List<String> encodings = new ArrayList<>(contentDecoder.size());
if (contentDecoderMap != null) {
final List<String> encodings = new ArrayList<>(contentDecoderMap.size());
final RegistryBuilder<UnaryOperator<HttpEntity>> b2 = RegistryBuilder.create();
for (final Map.Entry<ContentCoding, UnaryOperator<HttpEntity>> entry : contentDecoder.entrySet()) {
final String token = entry.getKey().token();
for (final Map.Entry<String, InputStreamFactory> 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<UnaryOperator<HttpEntity>> decoderRegistry = b2.build();

Expand Down