public ClientResponse execute(String method, String uri, RequestEntity entity, RequestOptions options) {
boolean usecache = useCache(method, options);
options = options != null ? options : getDefaultRequestOptions();
try {
Cache cache = getCache();
CachedResponse cached_response = cache.get(uri);
switch (getCacheDisposition(usecache, uri, options, cached_response)) {
case FRESH: // CACHE HIT: FRESH
if (cached_response != null)
return checkRequestException(cached_response, options);
case STALE: // CACHE HIT: STALE
// revalidate the cached entry
if (cached_response != null) {
if (cached_response.getEntityTag() != null)
options.setIfNoneMatch(cached_response.getEntityTag().toString());
else if (cached_response.getLastModified() != null)
options.setIfModifiedSince(cached_response.getLastModified());
else
options.setNoCache(true);
}
default: // CACHE MISS
HttpMethod httpMethod = MethodHelper.createMethod(method, uri, entity, options);