Class CachingHttpAsyncClient
- java.lang.Object
-
- org.apache.http.impl.client.cache.CachingHttpAsyncClient
-
- All Implemented Interfaces:
HttpAsyncClient
@Contract(threading=SAFE) public class CachingHttpAsyncClient extends Object implements HttpAsyncClient
-
-
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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.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.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> 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> 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.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.boolean
isSharedCache()
Reports whether thisCachingHttpClient
is configured as a shared (public) or non-shared (private) cache.boolean
supportsRangeAndContentRangeHeaders()
Reports whether thisCachingHttpClient
implementation supports byte-range requests as specified by theRange
andContent-Range
headers.
-
-
-
Constructor Detail
-
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)
-
-
Method Detail
-
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 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> 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> 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 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 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 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.
-
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
-
-