arturobernalg commented on code in PR #456:
URL: 
https://github.com/apache/httpcomponents-client/pull/456#discussion_r1233374525


##########
httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java:
##########
@@ -2123,7 +2123,13 @@ public void 
testAgeHeaderPopulatedFromCacheEntryCurrentAge() throws Exception {
         final ClassicHttpResponse result = execute(request);
 
         Assertions.assertEquals(200, result.getCode());
-        Assertions.assertEquals("11", result.getFirstHeader("Age").getValue());
+        // We calculate the age of the cache entry as per RFC 9111:
+        // We first find the "corrected_initial_age" which is the maximum of 
"apparentAge" and "correctedReceivedAge".
+        // In this case, max(1, 2) = 2 seconds.
+        // We then add the "residentTime" which is "now - responseTime",
+        // which is the current time minus the time the cache entry was 
created. In this case, that is 8 seconds.
+        // So, the total age is "corrected_initial_age" + "residentTime" = 2 + 
8 = 10 seconds.
+        Assertions.assertEquals("10", result.getFirstHeader("Age").getValue());

Review Comment:
   @ok2c 
   The current implementation of ContainsHeaderMatcher does not directly 
support the object types we're working with here, such as ClassicHttpResponse. 
Adapting it to these types may require significant changes to the existing 
code. Maybe I'm missing something. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to