Class CachedHttpResponseGenerator
java.lang.Object
org.apache.hc.client5.http.impl.cache.CachedHttpResponseGenerator
Rebuilds an
HttpResponse from a HttpCacheEntry-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddMissingContentLengthHeader(org.apache.hc.core5.http.HttpResponse response, byte[] body) (package private) SimpleHttpResponseGenerate 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.getErrorForRequest(RequestProtocolError errorCheck) Extract error information about theHttpRequesttelling the 'caller' that a problem occurred.private booleanresponseShouldContainEntity(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry cacheEntry) private booleantransferEncodingIsPresent(org.apache.hc.core5.http.HttpResponse response)
-
Field Details
-
validityStrategy
-
-
Constructor Details
-
CachedHttpResponseGenerator
CachedHttpResponseGenerator(CacheValidityPolicy validityStrategy)
-
-
Method Details
-
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
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
Extract error information about theHttpRequesttelling the 'caller' that a problem occurred.- Parameters:
errorCheck- What type of error should I get- Returns:
- The
HttpResponsethat is the error generated
-