From 3b5c815f5c524ca76e51da365318a825b864d3db Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Fri, 6 Sep 2024 19:32:46 +0200 Subject: [PATCH] HTTPCLIENT-2338: put compress exec interceptor after retry exec interceptor --- .../http/impl/classic/HttpClientBuilder.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java index 266297a593..4ba68b9192 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java @@ -962,6 +962,22 @@ public CloseableHttpClient build() { authCachingDisabled), ChainElement.PROTOCOL.name()); + if (!contentCompressionDisabled) { + if (contentDecoderMap != null) { + final List encodings = new ArrayList<>(contentDecoderMap.keySet()); + final RegistryBuilder b2 = RegistryBuilder.create(); + for (final Map.Entry entry: contentDecoderMap.entrySet()) { + b2.register(entry.getKey(), entry.getValue()); + } + final Registry 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 if (!automaticRetriesDisabled) { HttpRequestRetryStrategy retryStrategyCopy = this.retryStrategy; @@ -991,22 +1007,6 @@ public CloseableHttpClient build() { } } - if (!contentCompressionDisabled) { - if (contentDecoderMap != null) { - final List encodings = new ArrayList<>(contentDecoderMap.keySet()); - final RegistryBuilder b2 = RegistryBuilder.create(); - for (final Map.Entry entry: contentDecoderMap.entrySet()) { - b2.register(entry.getKey(), entry.getValue()); - } - final Registry 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 if (!redirectHandlingDisabled) { RedirectStrategy redirectStrategyCopy = this.redirectStrategy;