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 179fbcd8a..c812b12bd 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 @@ -711,7 +711,8 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH final Date responseDate1 = getCurrentDate(); final AsyncExecCallback callback1; - if (revalidationResponseIsTooOld(backendResponse1, cacheEntry)) { + if (revalidationResponseIsTooOld(backendResponse1, cacheEntry) + && (entityProducer == null || entityProducer.isRepeatable())) { final HttpRequest unconditional = conditionalRequestBuilder.buildUnconditionalRequest( scope.originalRequest); @@ -805,7 +806,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH @Override public void completed(final Map variants) { - if (variants != null && !variants.isEmpty()) { + if (variants != null && !variants.isEmpty() && (entityProducer == null || entityProducer.isRepeatable())) { negotiateResponseFromVariants(target, request, entityProducer, scope, chain, asyncExecCallback, variants); } else { callBackend(target, request, entityProducer, scope, chain, 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 724fa8a8c..7fb7e426b 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 @@ -447,7 +447,8 @@ public class CachingExec extends CachingExecBase implements ExecChainHandler { return callBackend(target, request, scope, chain); } - if (revalidationResponseIsTooOld(backendResponse, matchingVariant.getEntry())) { + if (revalidationResponseIsTooOld(backendResponse, matchingVariant.getEntry()) + && (request.getEntity() == null || request.getEntity().isRepeatable())) { EntityUtils.consume(backendResponse.getEntity()); backendResponse.close(); final ClassicHttpRequest unconditional = conditionalRequestBuilder.buildUnconditionalRequest(request);