HTTPCLIENT-2338: put compress exec interceptor after retry exec interceptor

This commit is contained in:
Oleg Kalnichevski 2024-09-06 19:32:46 +02:00
parent 12409713eb
commit 3b5c815f5c
1 changed files with 16 additions and 16 deletions

View File

@ -962,6 +962,22 @@ public class HttpClientBuilder {
authCachingDisabled), authCachingDisabled),
ChainElement.PROTOCOL.name()); ChainElement.PROTOCOL.name());
if (!contentCompressionDisabled) {
if (contentDecoderMap != null) {
final List<String> encodings = new ArrayList<>(contentDecoderMap.keySet());
final RegistryBuilder<InputStreamFactory> b2 = RegistryBuilder.create();
for (final Map.Entry<String, InputStreamFactory> entry: contentDecoderMap.entrySet()) {
b2.register(entry.getKey(), entry.getValue());
}
final Registry<InputStreamFactory> decoderRegistry = b2.build();
execChainDefinition.addFirst(
new ContentCompressionExec(encodings, decoderRegistry, true),
ChainElement.COMPRESS.name());
} else {
execChainDefinition.addFirst(new ContentCompressionExec(true), ChainElement.COMPRESS.name());
}
}
// Add request retry executor, if not disabled // Add request retry executor, if not disabled
if (!automaticRetriesDisabled) { if (!automaticRetriesDisabled) {
HttpRequestRetryStrategy retryStrategyCopy = this.retryStrategy; HttpRequestRetryStrategy retryStrategyCopy = this.retryStrategy;
@ -991,22 +1007,6 @@ public class HttpClientBuilder {
} }
} }
if (!contentCompressionDisabled) {
if (contentDecoderMap != null) {
final List<String> encodings = new ArrayList<>(contentDecoderMap.keySet());
final RegistryBuilder<InputStreamFactory> b2 = RegistryBuilder.create();
for (final Map.Entry<String, InputStreamFactory> entry: contentDecoderMap.entrySet()) {
b2.register(entry.getKey(), entry.getValue());
}
final Registry<InputStreamFactory> decoderRegistry = b2.build();
execChainDefinition.addFirst(
new ContentCompressionExec(encodings, decoderRegistry, true),
ChainElement.COMPRESS.name());
} else {
execChainDefinition.addFirst(new ContentCompressionExec(true), ChainElement.COMPRESS.name());
}
}
// Add redirect executor, if not disabled // Add redirect executor, if not disabled
if (!redirectHandlingDisabled) { if (!redirectHandlingDisabled) {
RedirectStrategy redirectStrategyCopy = this.redirectStrategy; RedirectStrategy redirectStrategyCopy = this.redirectStrategy;