You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2026/08/15 10:22:27 UTC

(httpcomponents-client) 01/01: Bug-fix: ResponseCachingPolicy incorrectly applies `neverCache1_1ResponsesWithQueryString` config parameter. This config parameter and related functionality will be deprecated in the next feature release and removed in the future.

This is an automated email from the ASF dual-hosted git repository.

ok2c pushed a commit to branch 5.6.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit e52d1558d4398194f513589114dea8e82f304fd3
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sat Aug 15 11:47:42 2026 +0200

    Bug-fix: ResponseCachingPolicy incorrectly applies `neverCache1_1ResponsesWithQueryString` config parameter. This config parameter and related functionality will be deprecated in the next feature release and removed in the future.
---
 .../org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java | 5 +++--
 .../apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java
index 93bd98e80..eb01b792e 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java
@@ -114,10 +114,11 @@ public boolean isResponseCacheable(final ResponseCacheControl cacheControl, fina
         }
 
         if (request.getPath().contains("?")) {
-            if (neverCache1_0ResponsesWithQueryString && from1_0Origin(response)) {
+            if (neverCache1_0ResponsesWithQueryString && from1_0Origin(response) || neverCache1_1ResponsesWithQueryString) {
                 LOG.debug("Response is not cacheable as it had a query string");
                 return false;
-            } else if (!neverCache1_1ResponsesWithQueryString && !isExplicitlyCacheable(cacheControl, response)) {
+            }
+            if (!isExplicitlyCacheable(cacheControl, response)) {
                 LOG.debug("Response is not cacheable as it is missing explicit caching headers");
                 return false;
             }
diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java
index a2128ef17..d51a4349f 100644
--- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java
+++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java
@@ -899,9 +899,9 @@ void testIsResponseCacheable() {
         request = new BasicHttpRequest("GET","/foo?s=bar");
         // HTTPbis working group says ok if explicitly indicated by
         // response headers
-        policy = new ResponseCachingPolicy(true, false, true);
         response.setCode(HttpStatus.SC_OK);
         response.setHeader("Date", DateUtils.formatStandardDate(now));
+        responseCacheControl = ResponseCacheControl.builder().setMaxAge(3600).build();
         assertTrue(policy.isResponseCacheable(responseCacheControl, request, response));
     }