From b08a6bef381224aa9a4c0b922f77334e1fd7f544 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 c040bf84d..0c6edea06 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 @@ -866,6 +866,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; @@ -895,22 +911,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;