Skip to content
Closed
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 @@ -28,6 +28,7 @@
package org.apache.hc.client5.http.impl.classic;

import java.io.Closeable;
import java.io.InputStream;
import java.net.ProxySelector;
import java.security.AccessController;
import java.security.PrivilegedAction;
Expand Down Expand Up @@ -58,6 +59,8 @@
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.entity.compress.IOFunction;
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,8 +218,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;
private String userAgent;
Expand All @@ -243,7 +244,7 @@ private ExecInterceptorEntry(
* Custom decoders keyed by {@link ContentCoding}.
*
*/
private LinkedHashMap<ContentCoding, UnaryOperator<HttpEntity>> contentDecoder;
private LinkedHashMap<String, UnaryOperator<HttpEntity>> contentDecoder;

public static HttpClientBuilder create() {
return new HttpClientBuilder();
Expand Down Expand Up @@ -706,11 +707,21 @@ public final HttpClientBuilder setDefaultCookieSpecRegistry(
* Sets a map of {@link org.apache.hc.client5.http.entity.InputStreamFactory}s
* to be used for automatic content decompression.
*
* @deprecated Populate via {@link #setContentDecoder(LinkedHashMap)}
*
* @return this instance.
*/
@Deprecated
public final HttpClientBuilder setContentDecoderRegistry(
final LinkedHashMap<String, InputStreamFactory> contentDecoderMap) {
this.contentDecoderMap = contentDecoderMap;
if (contentDecoderMap != null) {
final LinkedHashMap<String, UnaryOperator<HttpEntity>> map = new LinkedHashMap<>();
for (final Map.Entry<String, InputStreamFactory> e : contentDecoderMap.entrySet()) {
final IOFunction<InputStream, InputStream> decoderFunc = e.getValue()::create;
map.put(e.getKey(), srcEntity -> new DecompressingEntity(srcEntity, decoderFunc));
}
this.contentDecoder = map;
}
return this;
}

Expand All @@ -725,7 +736,7 @@ public final HttpClientBuilder setContentDecoderRegistry(
* @since 5.6
*/
public final HttpClientBuilder setContentDecoder(
final LinkedHashMap<ContentCoding, UnaryOperator<HttpEntity>> contentDecoder) {
final LinkedHashMap<String, UnaryOperator<HttpEntity>> contentDecoder) {
this.contentDecoder = contentDecoder;
return this;
}
Expand Down Expand Up @@ -995,8 +1006,8 @@ public CloseableHttpClient build() {
if (contentDecoder != null) {
final List<String> encodings = new ArrayList<>(contentDecoder.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, UnaryOperator<HttpEntity>> entry : contentDecoder.entrySet()) {
final String token = entry.getKey();
encodings.add(token);
b2.register(token, entry.getValue());
}
Expand Down
Loading