From 1bbf5f4371dc45a6d16e2c448d4b2003ce93ed9e Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 15 Nov 2023 15:16:56 +0100 Subject: [PATCH] Bug fix: when validating a cache entry the protocol handlers must use the current request message with additional headers generated by the previous request interceptors instead of the original request message --- .../org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java | 2 +- .../java/org/apache/hc/client5/http/impl/cache/CachingExec.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java index 0d7261a01..d994d4a73 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java @@ -770,7 +770,7 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler final Instant requestDate = getCurrentDate(); final HttpRequest conditionalRequest = conditionalRequestBuilder.buildConditionalRequest( responseCacheControl, - BasicRequestBuilder.copy(scope.originalRequest).build(), + BasicRequestBuilder.copy(request).build(), hit.entry); final HttpClientContext context = scope.clientContext; chainProceed(conditionalRequest, entityProducer, scope, chain, new AsyncExecCallback() { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java index 60e9f99af..7a42731e1 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java @@ -343,7 +343,7 @@ class CachingExec extends CachingExecBase implements ExecChainHandler { final HttpClientContext context = scope.clientContext; Instant requestDate = getCurrentDate(); final ClassicHttpRequest conditionalRequest = conditionalRequestBuilder.buildConditionalRequest( - responseCacheControl, scope.originalRequest, hit.entry); + responseCacheControl, request, hit.entry); ClassicHttpResponse backendResponse = chain.proceed(conditionalRequest, scope); try {