dxbjavid commented on code in PR #874:
URL:
https://github.com/apache/httpcomponents-client/pull/874#discussion_r3796505165
##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/ResponseCacheControl.java:
##########
@@ -60,6 +60,13 @@ public final class ResponseCacheControl implements
CacheControl {
* The shared-max-age directive value.
*/
private final long sharedMaxAge;
+ /**
+ * Indicates whether a valid {@code s-maxage} directive was present in the
header. This is distinct from
+ * {@link #sharedMaxAge} being {@code >= 0}, since a syntactically present
but malformed value (for example
+ * {@code s-maxage=foo}) is stored as {@code 0} rather than {@code -1}.
RFC 9111 treats such an invalid
+ * directive as absent, so this flag records whether the directive
genuinely applies.
+ */
+ private final boolean sharedMaxAgePresent;
Review Comment:
good point, dropped the boolean. parseSeconds now returns -Integer.MAX_VALUE
when the value isn't a valid delta-seconds, so a malformed directive is
distinct from both absent (-1) and a genuine 0. the shared-cache auth check
just treats anything below zero as not present, and i guarded the freshness
paths so the sentinel is never used as a duration.
##########
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheControlHeaderParser.java:
##########
@@ -244,6 +247,19 @@ private static long parseSeconds(final String name, final
String value) {
return delta;
}
+ private static boolean isDeltaSeconds(final String value) {
Review Comment:
moved it in, the malformed check lives inside parseSeconds now and returns
the sentinel there rather than being handled at the call site.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]