public ProviderResult retrieve(final SystemClock clock,
final Object key,
final CacheEntry entry) {
HttpContent httpContent;
CachedHttpContentState state = null;
HTTPResponseAccessor accessor;
boolean cacheable = false;
ProviderResult result = null;
try {
// check if validation headers can be added
if (entry != null) {
final CachedHttpContentState existingState =
(CachedHttpContentState) entry.getExtensionObject();
if (existingState != null) {
// this is a validation
// set the If-Modified-Since header using the stored
// last modified value (if there is any)
final Time lastModified = existingState.getLastModified();
if (lastModified != null) {
final String lastModifiedAsString;
// SimpleDateFormat is not thread safe
synchronized (RFC1123) {
lastModifiedAsString = RFC1123.format(
new Date(lastModified.inMillis()));
}
final Header header =
new HeaderImpl(HeaderNames.IF_MODIFIED_SINCE_HEADER);
header.setValue(lastModifiedAsString);
executor.addRequestHeader(header);
}
// set the If-None-Match header with the eTag value, if
// there is any
final String eTag = existingState.getETag();
if (eTag != null && eTag.trim().length() > 0) {
final Header header =
new HeaderImpl(HeaderNames.IF_NONE_MATCH_HEADER);
header.setValue(eTag);
executor.addRequestHeader(header);