Class CachedResponseSuitabilityChecker
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.CachedResponseSuitabilityChecker
-
class CachedResponseSuitabilityChecker extends java.lang.ObjectDetermines whether a givenHttpCacheEntryis suitable to be used as a response for a givenHttpRequest.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGprivate booleansharedCacheprivate booleanstaleifErrorprivate CacheValidityPolicyvalidityStrategy
-
Constructor Summary
Constructors Constructor Description CachedResponseSuitabilityChecker(CacheConfig config)CachedResponseSuitabilityChecker(CacheValidityPolicy validityStrategy, CacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallConditionalsMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.Instant now)Check that conditionals that are part of this request matchCacheSuitabilityassessSuitability(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.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, java.time.Instant now)(package private) booleanlastModifiedValidatorMatches(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.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 Detail
-
LOG
private static final org.slf4j.Logger LOG
-
validityStrategy
private final CacheValidityPolicy validityStrategy
-
sharedCache
private final boolean sharedCache
-
staleifError
private final boolean staleifError
-
-
Constructor Detail
-
CachedResponseSuitabilityChecker
CachedResponseSuitabilityChecker(CacheValidityPolicy validityStrategy, CacheConfig config)
-
CachedResponseSuitabilityChecker
CachedResponseSuitabilityChecker(CacheConfig config)
-
-
Method Detail
-
assessSuitability
public CacheSuitability assessSuitability(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.Instant now)
Determine if I can utilize the givenHttpCacheEntryto respond to the givenHttpRequest.- Since:
- 5.4
-
requestMethodMatch
boolean requestMethodMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
-
requestUriMatch
boolean requestUriMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
-
requestHeadersMatch
boolean requestHeadersMatch(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
-
isResponseNoCache
boolean isResponseNoCache(ResponseCacheControl responseCacheControl, HttpCacheEntry entry)
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, java.time.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
boolean etagValidatorMatches(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)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, java.time.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, java.time.Instant now)
-
-