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 AsynchronousAsyncValidator
asynchAsyncRevalidator
private HttpAsyncClient
backend
private org.apache.http.impl.client.cache.CacheableRequestPolicy
cacheableRequestPolicy
private java.util.concurrent.atomic.AtomicLong
cacheHits
private java.util.concurrent.atomic.AtomicLong
cacheMisses
private java.util.concurrent.atomic.AtomicLong
cacheUpdates
private org.apache.http.impl.client.cache.ConditionalRequestBuilder
conditionalRequestBuilder
private org.apache.commons.logging.Log
log
private long
maxObjectSizeBytes
private org.apache.http.impl.client.cache.RequestProtocolCompliance
requestCompliance
private org.apache.http.impl.client.cache.HttpCache
responseCache
private org.apache.http.impl.client.cache.ResponseCachingPolicy
responseCachingPolicy
private org.apache.http.impl.client.cache.ResponseProtocolCompliance
responseCompliance
private org.apache.http.impl.client.cache.CachedHttpResponseGenerator
responseGenerator
private boolean
sharedCache
private org.apache.http.impl.client.cache.CachedResponseSuitabilityChecker
suitabilityChecker
private static boolean
SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS
private org.apache.http.impl.client.cache.CacheValidityPolicy
validityPolicy
private 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 boolean
alreadyHaveNewerCacheEntry(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.HttpResponse backendResponse)
(package private) 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)
(package private) boolean
clientRequestsOurOptions(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 boolean
explicitFreshnessRequest(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)
private void
flushEntriesInvalidatedByRequest(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
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)
private org.apache.http.HttpResponse
generateGatewayTimeout(org.apache.http.client.cache.HttpCacheContext clientContext)
private java.lang.String
generateViaHeader(org.apache.http.HttpMessage msg)
long
getCacheHits()
Reports the number of times that the cache successfully responded to anHttpRequest
without contacting the origin server.long
getCacheMisses()
Reports the number of times that the cache contacted the origin server because it had no appropriate response cached.long
getCacheUpdates()
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.Date
getCurrentDate()
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.HttpResponse
getFatallyNoncompliantResponse(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheContext clientContext)
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)
(package private) 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)
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)
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)
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)
boolean
isSharedCache()
Reports whether thisCachingHttpClient
is configured as a shared (public) or non-shared (private) cache.private AsynchronousAsyncValidator
makeAsynchronousValidator(org.apache.http.impl.client.cache.CacheConfig config)
private boolean
mayCallBackend(org.apache.http.HttpRequest request)
(package private) 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)
private void
recordCacheHit(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
private void
recordCacheMiss(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
private void
recordCacheUpdate(org.apache.http.client.cache.HttpCacheContext clientContext)
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)
(package 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 cacheEntry)
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)
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)
private boolean
revalidationResponseIsTooOld(org.apache.http.HttpResponse backendResponse, org.apache.http.client.cache.HttpCacheEntry cacheEntry)
private org.apache.http.client.cache.HttpCacheEntry
satisfyFromCache(org.apache.http.HttpHost target, org.apache.http.HttpRequest request)
private void
setResponseStatus(org.apache.http.client.cache.HttpCacheContext clientContext, org.apache.http.client.cache.CacheResponseStatus value)
private boolean
shouldSendNotModifiedResponse(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry responseEntry)
private boolean
staleIfErrorAppliesTo(int statusCode)
private boolean
staleResponseNotAllowed(org.apache.http.HttpRequest request, org.apache.http.client.cache.HttpCacheEntry entry, java.util.Date now)
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.boolean
supportsRangeAndContentRangeHeaders()
Reports whether thisCachingHttpClient
implementation supports byte-range requests as specified by theRange
andContent-Range
headers.private void
tryToUpdateVariantMap(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.impl.client.cache.Variant matchingVariant)
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)
-
-
-
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 anHttpRequest
without 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:HttpAsyncClient
Initiates asynchronous HTTP request execution against the given target.- Specified by:
execute
in interfaceHttpAsyncClient
- Parameters:
target
- the target host for the request. Implementations may acceptnull
if 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:HttpAsyncClient
Initiates 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:
execute
in 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:HttpAsyncClient
Initiates 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:
execute
in 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:HttpAsyncClient
Initiates asynchronous HTTP request execution.- Specified by:
execute
in 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:HttpAsyncClient
Initiates 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:
execute
in 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:HttpAsyncClient
Initiates 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:
execute
in interfaceHttpAsyncClient
- Parameters:
target
- the target host for the request. Implementations may acceptnull
if 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, ornull
to 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 thisCachingHttpClient
implementation supports byte-range requests as specified by theRange
andContent-Range
headers.- Returns:
true
if byte-range requests are supported
-
isSharedCache
public boolean isSharedCache()
Reports whether thisCachingHttpClient
is configured as a shared (public) or non-shared (private) cache. SeeCacheConfig.setSharedCache(boolean)
.- Returns:
true
if 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)
-
-