Class AsyncCachingExec
java.lang.Object
org.apache.hc.client5.http.impl.cache.CachingExecBase
org.apache.hc.client5.http.impl.cache.AsyncCachingExec
- All Implemented Interfaces:
AsyncExecChainHandler
@Contract(threading=SAFE)
class AsyncCachingExec
extends CachingExecBase
implements AsyncExecChainHandler
Request executor in the request execution chain that is responsible for
transparent client-side caching.
The current implementation is conditionally compliant with HTTP/1.1 (meaning all the MUST and MUST NOTs are obeyed), although quite a lot, though not all, of the SHOULDs and SHOULD NOTs are obeyed too.
- Since:
- 5.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) class
(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DefaultAsyncCacheRevalidator
private final ConditionalRequestBuilder
<org.apache.hc.core5.http.HttpRequest> private static final org.slf4j.Logger
private final HttpAsyncCache
Fields inherited from class org.apache.hc.client5.http.impl.cache.CachingExecBase
cacheableRequestPolicy, cacheConfig, cacheHits, cacheMisses, cacheUpdates, requestCompliance, responseCachingPolicy, responseCompliance, responseGenerator, suitabilityChecker, SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS, validityPolicy, viaHeaders
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncCachingExec
(ResourceFactory resourceFactory, HttpAsyncCacheStorage storage, ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config) AsyncCachingExec
(HttpAsyncCache cache, ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config) AsyncCachingExec
(HttpAsyncCache responseCache, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, DefaultAsyncCacheRevalidator cacheRevalidator, ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> conditionalRequestBuilder, CacheConfig config) AsyncCachingExec
(HttpAsyncCache cache, DefaultAsyncCacheRevalidator cacheRevalidator, CacheConfig config) -
Method Summary
Modifier and TypeMethodDescription(package private) void
callBackend
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) (package private) void
chainProceed
(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) void
execute
(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) Executes the actual HTTP request.private void
handleCacheHit
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry entry) private void
handleCacheMiss
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) (package private) void
negotiateResponseFromVariants
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, Map<String, Variant> variants) (package private) void
revalidateCacheEntry
(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry cacheEntry) private void
triggerResponse
(SimpleHttpResponse cacheResponse, AsyncExecChain.Scope scope, AsyncExecCallback asyncExecCallback) Methods inherited from class org.apache.hc.client5.http.impl.cache.CachingExecBase
clientRequestsOurOptions, explicitFreshnessRequest, generateCachedResponse, generateGatewayTimeout, generateViaHeader, getCacheHits, getCacheMisses, getCacheUpdates, getCurrentDate, getFatallyNonCompliantResponse, handleRevalidationFailure, mayCallBackend, recordCacheFailure, recordCacheHit, recordCacheMiss, recordCacheUpdate, revalidationResponseIsTooOld, setResponseStatus, shouldSendNotModifiedResponse, staleIfErrorAppliesTo, staleResponseNotAllowed, storeRequestIfModifiedSinceFor304Response, supportsRangeAndContentRangeHeaders, unvalidatedCacheHit
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
responseCache
-
cacheRevalidator
-
conditionalRequestBuilder
private final ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> conditionalRequestBuilder
-
-
Constructor Details
-
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache cache, DefaultAsyncCacheRevalidator cacheRevalidator, CacheConfig config) -
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache responseCache, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, DefaultAsyncCacheRevalidator cacheRevalidator, ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> conditionalRequestBuilder, CacheConfig config) -
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache cache, ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config) -
AsyncCachingExec
AsyncCachingExec(ResourceFactory resourceFactory, HttpAsyncCacheStorage storage, ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config)
-
-
Method Details
-
triggerResponse
private void triggerResponse(SimpleHttpResponse cacheResponse, AsyncExecChain.Scope scope, AsyncExecCallback asyncExecCallback) -
execute
public void execute(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) throws org.apache.hc.core5.http.HttpException, IOException Description copied from interface:AsyncExecChainHandler
Executes the actual HTTP request. The handler can choose to return a response message immediately inside the call or asynchronously at some later point or delegate request execution to the next element in the execution chain.- Specified by:
execute
in interfaceAsyncExecChainHandler
- Parameters:
request
- the actual request.entityProducer
- the request entity producer ornull
if the request does not enclose an entity.scope
- the execution scope .chain
- the next element in the request execution chain.asyncExecCallback
- the execution callback.- Throws:
org.apache.hc.core5.http.HttpException
IOException
-
chainProceed
void chainProceed(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) -
callBackend
void callBackend(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) -
handleCacheHit
private void handleCacheHit(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry entry) -
revalidateCacheEntry
void revalidateCacheEntry(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry cacheEntry) -
handleCacheMiss
private void handleCacheMiss(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) -
negotiateResponseFromVariants
void negotiateResponseFromVariants(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, Map<String, Variant> variants)
-