Class CachedHttpResponseGenerator
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.CachedHttpResponseGenerator
-
class CachedHttpResponseGenerator extends java.lang.ObjectRebuilds anHttpResponsefrom aHttpCacheEntry
-
-
Field Summary
Fields Modifier and Type Field Description private CacheValidityPolicyvalidityStrategy
-
Constructor Summary
Constructors Constructor Description CachedHttpResponseGenerator(CacheValidityPolicy validityStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidgenerateContentLength(org.apache.hc.core5.http.HttpResponse response, byte[] body)(package private) SimpleHttpResponsegenerateNotModifiedResponse(HttpCacheEntry entry)Generate a 304 - Not Modified response from theHttpCacheEntry.(package private) SimpleHttpResponsegenerateResponse(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)If it is legal to use cached content in response response to theHttpRequestthen generate anHttpResponsebased onHttpCacheEntry.private booleanresponseShouldContainEntity(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry cacheEntry)
-
-
-
Field Detail
-
validityStrategy
private final CacheValidityPolicy validityStrategy
-
-
Constructor Detail
-
CachedHttpResponseGenerator
CachedHttpResponseGenerator(CacheValidityPolicy validityStrategy)
-
-
Method Detail
-
generateResponse
SimpleHttpResponse generateResponse(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) throws ResourceIOException
If it is legal to use cached content in response response to theHttpRequestthen generate anHttpResponsebased onHttpCacheEntry.- Parameters:
request-HttpRequestto generate the response forentry-HttpCacheEntryto transform into anHttpResponse- Returns:
SimpleHttpResponseconstructed response- Throws:
ResourceIOException
-
generateNotModifiedResponse
SimpleHttpResponse generateNotModifiedResponse(HttpCacheEntry entry)
Generate a 304 - Not Modified response from theHttpCacheEntry. This should be used to respond to conditional requests, when the entry exists or has been re-validated.
-
generateContentLength
private void generateContentLength(org.apache.hc.core5.http.HttpResponse response, byte[] body)
-
responseShouldContainEntity
private boolean responseShouldContainEntity(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry cacheEntry)
-
-