Class CachingExecBase
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.CachingExecBase
-
- Direct Known Subclasses:
AsyncCachingExec,CachingExec
public class CachingExecBase extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description (package private) CacheableRequestPolicycacheableRequestPolicy(package private) CacheConfigcacheConfig(package private) java.util.concurrent.atomic.AtomicLongcacheHits(package private) java.util.concurrent.atomic.AtomicLongcacheMisses(package private) java.util.concurrent.atomic.AtomicLongcacheUpdatesprivate static org.slf4j.LoggerLOG(package private) RequestProtocolCompliancerequestCompliance(package private) ResponseCachingPolicyresponseCachingPolicy(package private) ResponseProtocolComplianceresponseCompliance(package private) CachedHttpResponseGeneratorresponseGenerator(package private) CachedResponseSuitabilityCheckersuitabilityChecker(package private) static booleanSUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS(package private) CacheValidityPolicyvalidityPolicy(package private) java.util.Map<org.apache.hc.core5.http.ProtocolVersion,java.lang.String>viaHeaders
-
Constructor Summary
Constructors Constructor Description CachingExecBase(CacheConfig config)CachingExecBase(CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, CacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleanclientRequestsOurOptions(org.apache.hc.core5.http.HttpRequest request)(package private) booleanexplicitFreshnessRequest(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.Instant now)(package private) SimpleHttpResponsegenerateCachedResponse(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, java.time.Instant now)(package private) SimpleHttpResponsegenerateGatewayTimeout(org.apache.hc.core5.http.protocol.HttpContext context)(package private) java.lang.StringgenerateViaHeader(org.apache.hc.core5.http.HttpMessage msg)longgetCacheHits()Reports the number of times that the cache successfully responded to anHttpRequestwithout contacting the origin server.longgetCacheMisses()Reports the number of times that the cache contacted the origin server because it had no appropriate response cached.longgetCacheUpdates()Reports the number of times that the cache was able to satisfy a response by revalidating an existing but stale cache entry.(package private) java.time.InstantgetCurrentDate()(package private) SimpleHttpResponsegetFatallyNonCompliantResponse(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context)(package private) SimpleHttpResponsehandleRevalidationFailure(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, java.time.Instant now)(package private) booleanmayCallBackend(org.apache.hc.core5.http.HttpRequest request)(package private) voidrecordCacheFailure(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request)(package private) voidrecordCacheHit(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request)(package private) voidrecordCacheMiss(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request)(package private) voidrecordCacheUpdate(org.apache.hc.core5.http.protocol.HttpContext context)(package private) booleanrevalidationResponseIsTooOld(org.apache.hc.core5.http.HttpResponse backendResponse, HttpCacheEntry cacheEntry)(package private) voidsetResponseStatus(org.apache.hc.core5.http.protocol.HttpContext context, CacheResponseStatus value)(package private) booleanshouldSendNotModifiedResponse(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry responseEntry)(package private) booleanstaleIfErrorAppliesTo(int statusCode)(package private) booleanstaleResponseNotAllowed(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.Instant now)(package private) voidstoreRequestIfModifiedSinceFor304Response(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse backendResponse)For 304 Not modified responses, adds a "Last-Modified" header with the value of the "If-Modified-Since" header passed in the request.(package private) booleansupportsRangeAndContentRangeHeaders()Reports whether thisCachingHttpClientimplementation supports byte-range requests as specified by theRangeandContent-Rangeheaders.(package private) SimpleHttpResponseunvalidatedCacheHit(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry)
-
-
-
Field Detail
-
SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS
static final boolean SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS
- See Also:
- Constant Field Values
-
cacheHits
final java.util.concurrent.atomic.AtomicLong cacheHits
-
cacheMisses
final java.util.concurrent.atomic.AtomicLong cacheMisses
-
cacheUpdates
final java.util.concurrent.atomic.AtomicLong cacheUpdates
-
viaHeaders
final java.util.Map<org.apache.hc.core5.http.ProtocolVersion,java.lang.String> viaHeaders
-
responseCachingPolicy
final ResponseCachingPolicy responseCachingPolicy
-
validityPolicy
final CacheValidityPolicy validityPolicy
-
responseGenerator
final CachedHttpResponseGenerator responseGenerator
-
cacheableRequestPolicy
final CacheableRequestPolicy cacheableRequestPolicy
-
suitabilityChecker
final CachedResponseSuitabilityChecker suitabilityChecker
-
responseCompliance
final ResponseProtocolCompliance responseCompliance
-
requestCompliance
final RequestProtocolCompliance requestCompliance
-
cacheConfig
final CacheConfig cacheConfig
-
LOG
private static final org.slf4j.Logger LOG
-
-
Constructor Detail
-
CachingExecBase
CachingExecBase(CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, CacheConfig config)
-
CachingExecBase
CachingExecBase(CacheConfig config)
-
-
Method Detail
-
getCacheHits
public long getCacheHits()
Reports the number of times that the cache successfully responded to anHttpRequestwithout contacting the origin server.- Returns:
- the number of cache hits
-
getCacheMisses
public long getCacheMisses()
Reports the number of times that the cache contacted the origin server because it had no appropriate response cached.- Returns:
- the number of cache misses
-
getCacheUpdates
public long getCacheUpdates()
Reports the number of times that the cache was able to satisfy a response by revalidating an existing but stale cache entry.- Returns:
- the number of cache revalidations
-
getFatallyNonCompliantResponse
SimpleHttpResponse getFatallyNonCompliantResponse(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context)
- Since:
- 5.2
-
recordCacheMiss
void recordCacheMiss(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request)
-
recordCacheHit
void recordCacheHit(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request)
-
recordCacheFailure
void recordCacheFailure(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request)
-
recordCacheUpdate
void recordCacheUpdate(org.apache.hc.core5.http.protocol.HttpContext context)
-
generateCachedResponse
SimpleHttpResponse generateCachedResponse(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, java.time.Instant now) throws ResourceIOException
- Throws:
ResourceIOException
-
handleRevalidationFailure
SimpleHttpResponse handleRevalidationFailure(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry, java.time.Instant now) throws java.io.IOException
- Throws:
java.io.IOException
-
generateGatewayTimeout
SimpleHttpResponse generateGatewayTimeout(org.apache.hc.core5.http.protocol.HttpContext context)
-
unvalidatedCacheHit
SimpleHttpResponse unvalidatedCacheHit(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context, HttpCacheEntry entry) throws java.io.IOException
- Throws:
java.io.IOException
-
staleResponseNotAllowed
boolean staleResponseNotAllowed(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.Instant now)
-
mayCallBackend
boolean mayCallBackend(org.apache.hc.core5.http.HttpRequest request)
-
explicitFreshnessRequest
boolean explicitFreshnessRequest(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry, java.time.Instant now)
-
generateViaHeader
java.lang.String generateViaHeader(org.apache.hc.core5.http.HttpMessage msg)
-
setResponseStatus
void setResponseStatus(org.apache.hc.core5.http.protocol.HttpContext context, CacheResponseStatus value)
-
supportsRangeAndContentRangeHeaders
boolean supportsRangeAndContentRangeHeaders()
Reports whether thisCachingHttpClientimplementation supports byte-range requests as specified by theRangeandContent-Rangeheaders.- Returns:
trueif byte-range requests are supported
-
getCurrentDate
java.time.Instant getCurrentDate()
-
clientRequestsOurOptions
boolean clientRequestsOurOptions(org.apache.hc.core5.http.HttpRequest request)
-
revalidationResponseIsTooOld
boolean revalidationResponseIsTooOld(org.apache.hc.core5.http.HttpResponse backendResponse, HttpCacheEntry cacheEntry)
-
shouldSendNotModifiedResponse
boolean shouldSendNotModifiedResponse(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry responseEntry)
-
staleIfErrorAppliesTo
boolean staleIfErrorAppliesTo(int statusCode)
-
storeRequestIfModifiedSinceFor304Response
void storeRequestIfModifiedSinceFor304Response(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse backendResponse)For 304 Not modified responses, adds a "Last-Modified" header with the value of the "If-Modified-Since" header passed in the request. This header is required to be able to reuse match the cache entry for subsequent requests but as defined in http specifications it is not included in 304 responses by backend servers. This header will not be included in the resulting response.
-
-