Class CachedHttpResponseGenerator
- java.lang.Object
-
- org.apache.http.impl.client.cache.CachedHttpResponseGenerator
-
@Contract(threading=IMMUTABLE_CONDITIONAL) class CachedHttpResponseGenerator extends java.lang.Object
Rebuilds anHttpResponse
from anet.sf.ehcache.CacheEntry
- Since:
- 4.1
-
-
Field Summary
Fields Modifier and Type Field Description private CacheValidityPolicy
validityStrategy
-
Constructor Summary
Constructors Constructor Description CachedHttpResponseGenerator()
CachedHttpResponseGenerator(CacheValidityPolicy validityStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addMissingContentLengthHeader(org.apache.http.HttpResponse response, org.apache.http.HttpEntity entity)
(package private) CloseableHttpResponse
generateNotModifiedResponse(HttpCacheEntry entry)
Generate a 304 - Not Modified response from aCacheEntity
.(package private) CloseableHttpResponse
generateResponse(HttpRequestWrapper request, HttpCacheEntry entry)
If I was able to use aCacheEntity
to response to theHttpRequest
then generate anHttpResponse
based on the cache entry.private boolean
responseShouldContainEntity(HttpRequestWrapper request, HttpCacheEntry cacheEntry)
private boolean
transferEncodingIsPresent(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 aCacheEntity
to response to theHttpRequest
then generate anHttpResponse
based on the cache entry.- Parameters:
request
-HttpRequestWrapper
to generate the response forentry
-CacheEntity
to transform into anHttpResponse
- Returns:
HttpResponse
that 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)
-
-