Class CachedResponseSuitabilityChecker
java.lang.Object
org.apache.hc.client5.http.impl.cache.CachedResponseSuitabilityChecker
Determines whether a given
HttpCacheEntry is suitable to be
used as a response for a given HttpRequest.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate final booleanprivate final booleanprivate final CacheValidityPolicy -
Constructor Summary
ConstructorsConstructorDescriptionCachedResponseSuitabilityChecker(CacheValidityPolicy validityStrategy, CacheConfig config) -
Method Summary
Modifier and TypeMethodDescriptionbooleanallConditionalsMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) Check that conditionals that are part of this request matchassessSuitability(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) Determine if I can utilize the givenHttpCacheEntryto respond to the givenHttpRequest.(package private) booleanetagValidatorMatches(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) Check entry against If-None-Match(package private) booleanhasSupportedEtagValidator(org.apache.hc.core5.http.HttpRequest request) (package private) booleanhasSupportedLastModifiedValidator(org.apache.hc.core5.http.HttpRequest request) (package private) booleanhasUnsupportedConditionalHeaders(org.apache.hc.core5.http.HttpRequest request) booleanisConditional(org.apache.hc.core5.http.HttpRequest request) Is this request the type of conditional request we support?(package private) booleanisResponseNoCache(ResponseCacheControl responseCacheControl, HttpCacheEntry entry) Determines if the givenHttpCacheEntryrequires revalidation based on the presence of theno-cachedirective in the Cache-Control header.booleanisSuitableIfError(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, HttpCacheEntry entry, Instant now) (package private) booleanlastModifiedValidatorMatches(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) Check entry against If-Modified-Since, if If-Modified-Since is in the future it is invalid(package private) booleanrequestHeadersMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) (package private) booleanrequestMethodMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) (package private) booleanrequestUriMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
validityStrategy
-
staleifError
private final boolean staleifError
-
-
Constructor Details
-
CachedResponseSuitabilityChecker
CachedResponseSuitabilityChecker(CacheValidityPolicy validityStrategy, CacheConfig config) -
CachedResponseSuitabilityChecker
CachedResponseSuitabilityChecker(CacheConfig config)
-
-
Method Details
-
assessSuitability
public CacheSuitability assessSuitability(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) Determine if I can utilize the givenHttpCacheEntryto respond to the givenHttpRequest.- Since:
- 5.4
-
requestMethodMatch
-
requestUriMatch
-
requestHeadersMatch
-
isResponseNoCache
Determines if the givenHttpCacheEntryrequires revalidation based on the presence of theno-cachedirective in the Cache-Control header.The method returns true in the following cases: - If the
no-cachedirective is present without any field names (unqualified). - If theno-cachedirective is present with field names, and at least one of these field names is present in the headers of theHttpCacheEntry.If the
no-cachedirective is not present in the Cache-Control header, the method returnsfalse. -
isConditional
public boolean isConditional(org.apache.hc.core5.http.HttpRequest request) Is this request the type of conditional request we support?- Parameters:
request- The current httpRequest being made- Returns:
trueif the request is supported
-
allConditionalsMatch
public boolean allConditionalsMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) Check that conditionals that are part of this request match- Parameters:
request- The current httpRequest being madeentry- the cache entrynow- right NOW in time- Returns:
trueif the request matches all conditionals
-
hasUnsupportedConditionalHeaders
boolean hasUnsupportedConditionalHeaders(org.apache.hc.core5.http.HttpRequest request) -
hasSupportedEtagValidator
boolean hasSupportedEtagValidator(org.apache.hc.core5.http.HttpRequest request) -
hasSupportedLastModifiedValidator
boolean hasSupportedLastModifiedValidator(org.apache.hc.core5.http.HttpRequest request) -
etagValidatorMatches
Check entry against If-None-Match- Parameters:
request- The current httpRequest being madeentry- the cache entry- Returns:
- boolean does the etag validator match
-
lastModifiedValidatorMatches
boolean lastModifiedValidatorMatches(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, Instant now) Check entry against If-Modified-Since, if If-Modified-Since is in the future it is invalid- Parameters:
request- The current httpRequest being madeentry- the cache entrynow- right NOW in time- Returns:
- boolean Does the last modified header match
-
isSuitableIfError
public boolean isSuitableIfError(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, HttpCacheEntry entry, Instant now)
-