Class CachedHttpResponseGenerator
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.CachedHttpResponseGenerator
-
class CachedHttpResponseGenerator extends java.lang.Object
Rebuilds anHttpResponse
from aHttpCacheEntry
-
-
Field Summary
Fields Modifier and Type Field Description private CacheValidityPolicy
validityStrategy
-
Constructor Summary
Constructors Constructor Description CachedHttpResponseGenerator(CacheValidityPolicy validityStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addMissingContentLengthHeader(org.apache.hc.core5.http.HttpResponse response, byte[] body)
(package private) SimpleHttpResponse
generateNotModifiedResponse(HttpCacheEntry entry)
Generate a 304 - Not Modified response from theHttpCacheEntry
.(package private) SimpleHttpResponse
generateResponse(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
If it is legal to use cached content in response response to theHttpRequest
then generate anHttpResponse
based onHttpCacheEntry
.SimpleHttpResponse
getErrorForRequest(RequestProtocolError errorCheck)
Extract error information about theHttpRequest
telling the 'caller' that a problem occurred.private boolean
responseShouldContainEntity(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry cacheEntry)
private boolean
transferEncodingIsPresent(org.apache.hc.core5.http.HttpResponse response)
-
-
-
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 theHttpRequest
then generate anHttpResponse
based onHttpCacheEntry
.- Parameters:
request
-HttpRequest
to generate the response forentry
-HttpCacheEntry
to transform into anHttpResponse
- Returns:
SimpleHttpResponse
constructed 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.
-
addMissingContentLengthHeader
private void addMissingContentLengthHeader(org.apache.hc.core5.http.HttpResponse response, byte[] body)
-
transferEncodingIsPresent
private boolean transferEncodingIsPresent(org.apache.hc.core5.http.HttpResponse response)
-
responseShouldContainEntity
private boolean responseShouldContainEntity(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry cacheEntry)
-
getErrorForRequest
public SimpleHttpResponse getErrorForRequest(RequestProtocolError errorCheck)
Extract error information about theHttpRequest
telling the 'caller' that a problem occurred.- Parameters:
errorCheck
- What type of error should I get- Returns:
- The
HttpResponse
that is the error generated
-
-