Class CachedHttpResponseGenerator
- java.lang.Object
-
- org.apache.http.impl.client.cache.CachedHttpResponseGenerator
-
@Contract(threading=IMMUTABLE_CONDITIONAL) class CachedHttpResponseGenerator extends java.lang.ObjectRebuilds anHttpResponsefrom anet.sf.ehcache.CacheEntry- Since:
- 4.1
-
-
Field Summary
Fields Modifier and Type Field Description private CacheValidityPolicyvalidityStrategy
-
Constructor Summary
Constructors Constructor Description CachedHttpResponseGenerator()CachedHttpResponseGenerator(CacheValidityPolicy validityStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddMissingContentLengthHeader(org.apache.http.HttpResponse response, org.apache.http.HttpEntity entity)(package private) CloseableHttpResponsegenerateNotModifiedResponse(HttpCacheEntry entry)Generate a 304 - Not Modified response from aCacheEntity.(package private) CloseableHttpResponsegenerateResponse(HttpRequestWrapper request, HttpCacheEntry entry)If I was able to use aCacheEntityto response to theHttpRequestthen generate anHttpResponsebased on the cache entry.private booleanresponseShouldContainEntity(HttpRequestWrapper request, HttpCacheEntry cacheEntry)private booleantransferEncodingIsPresent(org.apache.http.HttpResponse response)
-
-
-
Field Detail
-
validityStrategy
private final CacheValidityPolicy validityStrategy
-
-
Constructor Detail
-
CachedHttpResponseGenerator
CachedHttpResponseGenerator(CacheValidityPolicy validityStrategy)
-
CachedHttpResponseGenerator
CachedHttpResponseGenerator()
-
-
Method Detail
-
generateResponse
CloseableHttpResponse generateResponse(HttpRequestWrapper request, HttpCacheEntry entry)
If I was able to use aCacheEntityto response to theHttpRequestthen generate anHttpResponsebased on the cache entry.- Parameters:
request-HttpRequestWrapperto generate the response forentry-CacheEntityto transform into anHttpResponse- Returns:
HttpResponsethat was constructed
-
generateNotModifiedResponse
CloseableHttpResponse generateNotModifiedResponse(HttpCacheEntry entry)
Generate a 304 - Not Modified response from aCacheEntity. This should be used to respond to conditional requests, when the entry exists or has been re-validated.
-
addMissingContentLengthHeader
private void addMissingContentLengthHeader(org.apache.http.HttpResponse response, org.apache.http.HttpEntity entity)
-
transferEncodingIsPresent
private boolean transferEncodingIsPresent(org.apache.http.HttpResponse response)
-
responseShouldContainEntity
private boolean responseShouldContainEntity(HttpRequestWrapper request, HttpCacheEntry cacheEntry)
-
-