Class CachingHttpAsyncClient
- java.lang.Object
-
- org.apache.http.impl.client.cache.CachingHttpAsyncClient
-
- All Implemented Interfaces:
HttpAsyncClient
@Contract(threading=SAFE) public class CachingHttpAsyncClient extends java.lang.Object implements HttpAsyncClient
-
-
Field Summary
Fields Modifier and Type Field Description private AsynchronousAsyncValidatorasynchAsyncRevalidatorprivate HttpAsyncClientbackendprivate org.apache.http.impl.client.cache.CacheableRequestPolicycacheableRequestPolicyprivate java.util.concurrent.atomic.AtomicLongcacheHitsprivate java.util.concurrent.atomic.AtomicLongcacheMissesprivate java.util.concurrent.atomic.AtomicLongcacheUpdatesprivate org.apache.http.impl.client.cache.ConditionalRequestBuilderconditionalRequestBuilderprivate org.apache.commons.logging.Loglogprivate longmaxObjectSizeBytesprivate org.apache.http.impl.client.cache.RequestProtocolCompliancerequestComplianceprivate org.apache.http.impl.client.cache.HttpCacheresponseCacheprivate org.apache.http.impl.client.cache.ResponseCachingPolicyresponseCachingPolicyprivate org.apache.http.impl.client.cache.ResponseProtocolComplianceresponseComplianceprivate org.apache.http.impl.client.cache.CachedHttpResponseGeneratorresponseGeneratorprivate booleansharedCacheprivate org.apache.http.impl.client.cache.CachedResponseSuitabilityCheckersuitabilityCheckerprivate static booleanSUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERSprivate org.apache.http.impl.client.cache.CacheValidityPolicyvalidityPolicyprivate java.util.Map<org.apache.http.ProtocolVersion,java.lang.String>viaHeaders
-
Constructor Summary
Constructors Constructor Description CachingHttpAsyncClient()CachingHttpAsyncClient(org.apache.http.impl.client.cache.CacheConfig config)CachingHttpAsyncClient(HttpAsyncClient client)CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.client.cache.HttpCacheStorage storage, org.apache.http.impl.client.cache.CacheConfig config)CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.client.cache.ResourceFactory resourceFactory, org.apache.http.client.cache.HttpCacheStorage storage, org.apache.http.impl.client.cache.CacheConfig config)CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.impl.client.cache.CacheConfig config)CachingHttpAsyncClient(HttpAsyncClient backend, org.apache.http.impl.client.cache.CacheValidityPolicy validityPolicy, org.apache.http.impl.client.cache.ResponseCachingPolicy responseCachingPolicy, org.apache.http.impl.client.cache.HttpCache responseCache, org.apache.http.impl.client.cache.CachedHttpResponseGenerator responseGenerator, org.apache.http.impl.client.cache.CacheableRequestPolicy cacheableRequestPolicy, org.apache.http.impl.client.cache.CachedResponseSuitabilityChecker suitabilityChecker, org.apache.http.impl.client.cache.ConditionalRequestBuilder conditionalRequestBuilder, org.apache.http.impl.client.cache.ResponseProtocolCompliance responseCompliance, org.apache.http.impl.client.cache.RequestProtocolCompliance requestCompliance)CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.impl.client.cache.HttpCache cache, org.apache.http.impl.client.cache.CacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanalreadyHaveNewerCacheEntry(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.HttpResponse backendResponse)(package private) voidcallBackend(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext)(package private) booleanclientRequestsOurOptions(org.apache.http.HttpRequest request)java.util.concurrent.Future<org.apache.http.HttpResponse>execute(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback)Initiates asynchronous HTTP request execution.java.util.concurrent.Future<org.apache.http.HttpResponse>execute(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.protocol.HttpContext context, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback)Initiates asynchronous HTTP request execution using the given context.java.util.concurrent.Future<org.apache.http.HttpResponse>execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback)Initiates asynchronous HTTP request execution against the given target.java.util.concurrent.Future<org.apache.http.HttpResponse>execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest originalRequest, org.apache.http.protocol.HttpContext context, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> futureCallback)Initiates asynchronous HTTP request execution against the given target using the given context.<T> java.util.concurrent.Future<T>execute(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer, org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T> responseConsumer, org.apache.http.concurrent.FutureCallback<T> callback)Initiates asynchronous HTTP request execution using the default context.<T> java.util.concurrent.Future<T>execute(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer, org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T> responseConsumer, org.apache.http.protocol.HttpContext context, org.apache.http.concurrent.FutureCallback<T> callback)Initiates asynchronous HTTP request execution using the given context.private booleanexplicitFreshnessRequest(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)private voidflushEntriesInvalidatedByRequest(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)private org.apache.http.HttpResponsegenerateCachedResponse(org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)private org.apache.http.HttpResponsegenerateGatewayTimeout(org.apache.http.client.cache.HttpCacheContext clientContext)private java.lang.StringgenerateViaHeader(org.apache.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.util.DategetCurrentDate()private java.util.Map<java.lang.String,org.apache.http.impl.client.cache.Variant>getExistingCacheVariants(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)private org.apache.http.HttpResponsegetFatallyNoncompliantResponse(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheContext clientContext)private org.apache.http.client.cache.HttpCacheEntrygetUpdatedVariantEntry(org.apache.http.HttpHost target, org.apache.http.HttpRequest conditionalRequest, java.util.Date requestDate, java.util.Date responseDate, org.apache.http.HttpResponse backendResponse, org.apache.http.impl.client.cache.Variant matchingVariant, org.apache.http.client.cache.HttpCacheEntry matchedEntry)(package private) org.apache.http.client.methods.CloseableHttpResponsehandleBackendResponse(org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, java.util.Date requestDate, java.util.Date responseDate, org.apache.http.client.methods.CloseableHttpResponse backendResponse)private voidhandleCacheHit(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry)private voidhandleCacheMiss(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext)private org.apache.http.HttpResponsehandleRevalidationFailure(org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)booleanisSharedCache()Reports whether thisCachingHttpClientis configured as a shared (public) or non-shared (private) cache.private AsynchronousAsyncValidatormakeAsynchronousValidator(org.apache.http.impl.client.cache.CacheConfig config)private booleanmayCallBackend(org.apache.http.HttpRequest request)(package private) voidnegotiateResponseFromVariants(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, java.util.Map<java.lang.String,org.apache.http.impl.client.cache.Variant> variants)private voidrecordCacheHit(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)private voidrecordCacheMiss(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)private voidrecordCacheUpdate(org.apache.http.client.cache.HttpCacheContext clientContext)private voidretryRequestUnconditionally(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry matchedEntry)(package private) voidrevalidateCacheEntry(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry cacheEntry)private voidrevalidateCacheEntry(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)private voidrevalidateCacheEntryCompleted(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry cacheEntry, org.apache.http.client.methods.HttpRequestWrapper conditionalRequest, java.util.Date requestDate, org.apache.http.HttpResponse httpResponse, java.util.Date responseDate)private booleanrevalidationResponseIsTooOld(org.apache.http.HttpResponse backendResponse, org.apache.http.client.cache.HttpCacheEntry cacheEntry)private org.apache.http.client.cache.HttpCacheEntrysatisfyFromCache(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)private voidsetResponseStatus(org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.CacheResponseStatus value)private booleanshouldSendNotModifiedResponse(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry responseEntry)private booleanstaleIfErrorAppliesTo(int statusCode)private booleanstaleResponseNotAllowed(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)private voidstoreRequestIfModifiedSinceFor304Response(org.apache.http.HttpRequest request, org.apache.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.booleansupportsRangeAndContentRangeHeaders()Reports whether thisCachingHttpClientimplementation supports byte-range requests as specified by theRangeandContent-Rangeheaders.private voidtryToUpdateVariantMap(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.impl.client.cache.Variant matchingVariant)private org.apache.http.HttpResponseunvalidatedCacheHit(org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheEntry entry)
-
-
-
Field Detail
-
SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS
private static final boolean SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS
- See Also:
- Constant Field Values
-
cacheHits
private final java.util.concurrent.atomic.AtomicLong cacheHits
-
cacheMisses
private final java.util.concurrent.atomic.AtomicLong cacheMisses
-
cacheUpdates
private final java.util.concurrent.atomic.AtomicLong cacheUpdates
-
viaHeaders
private final java.util.Map<org.apache.http.ProtocolVersion,java.lang.String> viaHeaders
-
backend
private final HttpAsyncClient backend
-
responseCache
private final org.apache.http.impl.client.cache.HttpCache responseCache
-
validityPolicy
private final org.apache.http.impl.client.cache.CacheValidityPolicy validityPolicy
-
responseCachingPolicy
private final org.apache.http.impl.client.cache.ResponseCachingPolicy responseCachingPolicy
-
responseGenerator
private final org.apache.http.impl.client.cache.CachedHttpResponseGenerator responseGenerator
-
cacheableRequestPolicy
private final org.apache.http.impl.client.cache.CacheableRequestPolicy cacheableRequestPolicy
-
suitabilityChecker
private final org.apache.http.impl.client.cache.CachedResponseSuitabilityChecker suitabilityChecker
-
conditionalRequestBuilder
private final org.apache.http.impl.client.cache.ConditionalRequestBuilder conditionalRequestBuilder
-
maxObjectSizeBytes
private final long maxObjectSizeBytes
-
sharedCache
private final boolean sharedCache
-
responseCompliance
private final org.apache.http.impl.client.cache.ResponseProtocolCompliance responseCompliance
-
requestCompliance
private final org.apache.http.impl.client.cache.RequestProtocolCompliance requestCompliance
-
asynchAsyncRevalidator
private final AsynchronousAsyncValidator asynchAsyncRevalidator
-
log
private final org.apache.commons.logging.Log log
-
-
Constructor Detail
-
CachingHttpAsyncClient
CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.impl.client.cache.HttpCache cache, org.apache.http.impl.client.cache.CacheConfig config)
-
CachingHttpAsyncClient
public CachingHttpAsyncClient() throws org.apache.http.nio.reactor.IOReactorException- Throws:
org.apache.http.nio.reactor.IOReactorException
-
CachingHttpAsyncClient
public CachingHttpAsyncClient(org.apache.http.impl.client.cache.CacheConfig config) throws org.apache.http.nio.reactor.IOReactorException- Throws:
org.apache.http.nio.reactor.IOReactorException
-
CachingHttpAsyncClient
public CachingHttpAsyncClient(HttpAsyncClient client)
-
CachingHttpAsyncClient
public CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.impl.client.cache.CacheConfig config)
-
CachingHttpAsyncClient
public CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.client.cache.ResourceFactory resourceFactory, org.apache.http.client.cache.HttpCacheStorage storage, org.apache.http.impl.client.cache.CacheConfig config)
-
CachingHttpAsyncClient
public CachingHttpAsyncClient(HttpAsyncClient client, org.apache.http.client.cache.HttpCacheStorage storage, org.apache.http.impl.client.cache.CacheConfig config)
-
CachingHttpAsyncClient
CachingHttpAsyncClient(HttpAsyncClient backend, org.apache.http.impl.client.cache.CacheValidityPolicy validityPolicy, org.apache.http.impl.client.cache.ResponseCachingPolicy responseCachingPolicy, org.apache.http.impl.client.cache.HttpCache responseCache, org.apache.http.impl.client.cache.CachedHttpResponseGenerator responseGenerator, org.apache.http.impl.client.cache.CacheableRequestPolicy cacheableRequestPolicy, org.apache.http.impl.client.cache.CachedResponseSuitabilityChecker suitabilityChecker, org.apache.http.impl.client.cache.ConditionalRequestBuilder conditionalRequestBuilder, org.apache.http.impl.client.cache.ResponseProtocolCompliance responseCompliance, org.apache.http.impl.client.cache.RequestProtocolCompliance requestCompliance)
-
-
Method Detail
-
makeAsynchronousValidator
private AsynchronousAsyncValidator makeAsynchronousValidator(org.apache.http.impl.client.cache.CacheConfig config)
-
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
-
execute
public java.util.concurrent.Future<org.apache.http.HttpResponse> execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback)Description copied from interface:HttpAsyncClientInitiates asynchronous HTTP request execution against the given target.- Specified by:
executein interfaceHttpAsyncClient- Parameters:
target- the target host for the request. Implementations may acceptnullif they can still determine a route, for example to a default target or by inspecting the request.request- the request to executecallback- future callback.- Returns:
- future representing pending completion of the operation.
-
execute
public <T> java.util.concurrent.Future<T> execute(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer, org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T> responseConsumer, org.apache.http.concurrent.FutureCallback<T> callback)Description copied from interface:HttpAsyncClientInitiates asynchronous HTTP request execution using the default context.The request producer passed to this method will be used to generate a request message and stream out its content without buffering it in memory. The response consumer passed to this method will be used to process a response message without buffering its content in memory.
- Specified by:
executein interfaceHttpAsyncClient- Type Parameters:
T- the result type of request execution.- Parameters:
requestProducer- request producer callback.responseConsumer- response consumer callaback.callback- future callback.- Returns:
- future representing pending completion of the operation.
-
execute
public <T> java.util.concurrent.Future<T> execute(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer, org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T> responseConsumer, org.apache.http.protocol.HttpContext context, org.apache.http.concurrent.FutureCallback<T> callback)Description copied from interface:HttpAsyncClientInitiates asynchronous HTTP request execution using the given context.The request producer passed to this method will be used to generate a request message and stream out its content without buffering it in memory. The response consumer passed to this method will be used to process a response message without buffering its content in memory.
Please note it may be unsafe to interact with the context instance while the request is still being executed.
- Specified by:
executein interfaceHttpAsyncClient- Type Parameters:
T- the result type of request execution.- Parameters:
requestProducer- request producer callback.responseConsumer- response consumer callaback.context- HTTP contextcallback- future callback.- Returns:
- future representing pending completion of the operation.
-
execute
public java.util.concurrent.Future<org.apache.http.HttpResponse> execute(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback)Description copied from interface:HttpAsyncClientInitiates asynchronous HTTP request execution.- Specified by:
executein interfaceHttpAsyncClient- Parameters:
request- the request to executecallback- future callback.- Returns:
- future representing pending completion of the operation.
-
execute
public java.util.concurrent.Future<org.apache.http.HttpResponse> execute(org.apache.http.client.methods.HttpUriRequest request, org.apache.http.protocol.HttpContext context, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> callback)Description copied from interface:HttpAsyncClientInitiates asynchronous HTTP request execution using the given context.Please note it may be unsafe to interact with the context instance while the request is still being executed.
- Specified by:
executein interfaceHttpAsyncClient- Parameters:
request- the request to executecontext- HTTP contextcallback- future callback.- Returns:
- future representing pending completion of the operation.
-
execute
public java.util.concurrent.Future<org.apache.http.HttpResponse> execute(org.apache.http.HttpHost target, org.apache.http.HttpRequest originalRequest, org.apache.http.protocol.HttpContext context, org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse> futureCallback)Description copied from interface:HttpAsyncClientInitiates asynchronous HTTP request execution against the given target using the given context.Please note it may be unsafe to interact with the context instance while the request is still being executed.
- Specified by:
executein interfaceHttpAsyncClient- Parameters:
target- the target host for the request. Implementations may acceptnullif they can still determine a route, for example to a default target or by inspecting the request.originalRequest- the request to executecontext- the context to use for the execution, ornullto use the default contextfutureCallback- future callback.- Returns:
- future representing pending completion of the operation.
-
handleCacheHit
private void handleCacheHit(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry) throws java.io.IOException- Throws:
java.io.IOException
-
revalidateCacheEntry
private void revalidateCacheEntry(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now) throws org.apache.http.client.ClientProtocolException- Throws:
org.apache.http.client.ClientProtocolException
-
handleCacheMiss
private void handleCacheMiss(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext)
-
satisfyFromCache
private org.apache.http.client.cache.HttpCacheEntry satisfyFromCache(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
-
getFatallyNoncompliantResponse
private org.apache.http.HttpResponse getFatallyNoncompliantResponse(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheContext clientContext)
-
getExistingCacheVariants
private java.util.Map<java.lang.String,org.apache.http.impl.client.cache.Variant> getExistingCacheVariants(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
-
recordCacheMiss
private void recordCacheMiss(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
-
recordCacheHit
private void recordCacheHit(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
-
recordCacheUpdate
private void recordCacheUpdate(org.apache.http.client.cache.HttpCacheContext clientContext)
-
flushEntriesInvalidatedByRequest
private void flushEntriesInvalidatedByRequest(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
-
generateCachedResponse
private org.apache.http.HttpResponse generateCachedResponse(org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)
-
handleRevalidationFailure
private org.apache.http.HttpResponse handleRevalidationFailure(org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)
-
generateGatewayTimeout
private org.apache.http.HttpResponse generateGatewayTimeout(org.apache.http.client.cache.HttpCacheContext clientContext)
-
unvalidatedCacheHit
private org.apache.http.HttpResponse unvalidatedCacheHit(org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheEntry entry)
-
staleResponseNotAllowed
private boolean staleResponseNotAllowed(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)
-
mayCallBackend
private boolean mayCallBackend(org.apache.http.HttpRequest request)
-
explicitFreshnessRequest
private boolean explicitFreshnessRequest(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)
-
generateViaHeader
private java.lang.String generateViaHeader(org.apache.http.HttpMessage msg)
-
setResponseStatus
private void setResponseStatus(org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.CacheResponseStatus value)
-
supportsRangeAndContentRangeHeaders
public boolean supportsRangeAndContentRangeHeaders()
Reports whether thisCachingHttpClientimplementation supports byte-range requests as specified by theRangeandContent-Rangeheaders.- Returns:
trueif byte-range requests are supported
-
isSharedCache
public boolean isSharedCache()
Reports whether thisCachingHttpClientis configured as a shared (public) or non-shared (private) cache. SeeCacheConfig.setSharedCache(boolean).- Returns:
trueif we are behaving as a shared (public) cache
-
getCurrentDate
java.util.Date getCurrentDate()
-
clientRequestsOurOptions
boolean clientRequestsOurOptions(org.apache.http.HttpRequest request)
-
callBackend
void callBackend(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext)
-
revalidationResponseIsTooOld
private boolean revalidationResponseIsTooOld(org.apache.http.HttpResponse backendResponse, org.apache.http.client.cache.HttpCacheEntry cacheEntry)
-
negotiateResponseFromVariants
void negotiateResponseFromVariants(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, java.util.Map<java.lang.String,org.apache.http.impl.client.cache.Variant> variants)
-
retryRequestUnconditionally
private void retryRequestUnconditionally(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry matchedEntry)
-
getUpdatedVariantEntry
private org.apache.http.client.cache.HttpCacheEntry getUpdatedVariantEntry(org.apache.http.HttpHost target, org.apache.http.HttpRequest conditionalRequest, java.util.Date requestDate, java.util.Date responseDate, org.apache.http.HttpResponse backendResponse, org.apache.http.impl.client.cache.Variant matchingVariant, org.apache.http.client.cache.HttpCacheEntry matchedEntry)
-
tryToUpdateVariantMap
private void tryToUpdateVariantMap(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.impl.client.cache.Variant matchingVariant)
-
shouldSendNotModifiedResponse
private boolean shouldSendNotModifiedResponse(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry responseEntry)
-
revalidateCacheEntry
void revalidateCacheEntry(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry cacheEntry) throws org.apache.http.ProtocolException- Throws:
org.apache.http.ProtocolException
-
revalidateCacheEntryCompleted
private void revalidateCacheEntryCompleted(org.apache.http.concurrent.BasicFuture<org.apache.http.HttpResponse> future, org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.HttpCacheEntry cacheEntry, org.apache.http.client.methods.HttpRequestWrapper conditionalRequest, java.util.Date requestDate, org.apache.http.HttpResponse httpResponse, java.util.Date responseDate)
-
staleIfErrorAppliesTo
private boolean staleIfErrorAppliesTo(int statusCode)
-
handleBackendResponse
org.apache.http.client.methods.CloseableHttpResponse handleBackendResponse(org.apache.http.HttpHost target, org.apache.http.client.methods.HttpRequestWrapper request, java.util.Date requestDate, java.util.Date responseDate, org.apache.http.client.methods.CloseableHttpResponse backendResponse) throws java.io.IOException- Throws:
java.io.IOException
-
storeRequestIfModifiedSinceFor304Response
private void storeRequestIfModifiedSinceFor304Response(org.apache.http.HttpRequest request, org.apache.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.
-
alreadyHaveNewerCacheEntry
private boolean alreadyHaveNewerCacheEntry(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.HttpResponse backendResponse)
-
-