RequestEntity entity,
RequestOptions options) {
boolean usecache = useCache(method,options);
options = options != null ? options : getDefaultRequestOptions();
try {
Cache cache = getCache();
CachedResponse cached_response = cache.get(uri, options);
CacheDisposition disp = getCacheDisposition(
usecache, uri, options, cached_response);
switch(disp) {
case FRESH: // CACHE HIT: FRESH
if (cached_response != null) {
checkRequestException(cached_response,options);
return cached_response;
}
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);
} else {
disp = CacheDisposition.TRANSPARENT;
}
default: // CACHE MISS
HttpMethod httpMethod =
MethodHelper.createMethod(
method, uri, entity, options);
client.executeMethod(httpMethod);
if (usecache &&
(httpMethod.getStatusCode() == 304 ||
httpMethod.getStatusCode() == 412) &&
cached_response != null) return cached_response;
ClientResponse response = new CommonsResponse(abdera,httpMethod);
response = options.getUseLocalCache() ?
response = cache.update(options, response, cached_response) :
response;
checkRequestException(response,options);
return response;
}
} catch (Throwable t) {