Class HttpCacheEntryFactory


  • @Contract(threading=IMMUTABLE)
    public class HttpCacheEntryFactory
    extends java.lang.Object
    Since:
    5.4
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      HttpCacheEntry copy​(HttpCacheEntry entry)
      Creates a copy of the given HttpCacheEntry.
      HttpCacheEntry create​(java.time.Instant requestInstant, java.time.Instant responseInstant, org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, Resource resource)
      Create a new HttpCacheEntry with the given Resource.
      HttpCacheEntry createRoot​(HttpCacheEntry latestVariant, java.util.Collection<java.lang.String> variants)
      Creates a new root HttpCacheEntry (parent of multiple variants).
      HttpCacheEntry createUpdated​(java.time.Instant requestInstant, java.time.Instant responseInstant, org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response, HttpCacheEntry entry)
      Creates updated entry with the new information from the response.
      (package private) static void ensureDate​(org.apache.hc.core5.http.message.HeaderGroup headers, java.time.Instant instant)  
      (package private) static org.apache.hc.core5.http.message.HeaderGroup filterHopByHopHeaders​(org.apache.hc.core5.http.HttpMessage message)
      This method should be provided by the core
      private static org.apache.hc.core5.http.message.HeaderGroup headers​(java.util.Iterator<org.apache.hc.core5.http.Header> it)  
      (package private) org.apache.hc.core5.http.message.HeaderGroup mergeHeaders​(HttpCacheEntry entry, org.apache.hc.core5.http.HttpResponse response)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpCacheEntryFactory

        public HttpCacheEntryFactory()
    • Method Detail

      • headers

        private static org.apache.hc.core5.http.message.HeaderGroup headers​(java.util.Iterator<org.apache.hc.core5.http.Header> it)
      • mergeHeaders

        org.apache.hc.core5.http.message.HeaderGroup mergeHeaders​(HttpCacheEntry entry,
                                                                  org.apache.hc.core5.http.HttpResponse response)
      • filterHopByHopHeaders

        static org.apache.hc.core5.http.message.HeaderGroup filterHopByHopHeaders​(org.apache.hc.core5.http.HttpMessage message)
        This method should be provided by the core
      • ensureDate

        static void ensureDate​(org.apache.hc.core5.http.message.HeaderGroup headers,
                               java.time.Instant instant)
      • createRoot

        public HttpCacheEntry createRoot​(HttpCacheEntry latestVariant,
                                         java.util.Collection<java.lang.String> variants)
        Creates a new root HttpCacheEntry (parent of multiple variants).
        Parameters:
        latestVariant - The most recently created variant entry
        variants - describing cache entries that are variants of this parent entry; this maps a "variant key" (derived from the varying request headers) to a "cache key" (where in the cache storage the particular variant is located)
      • create

        public HttpCacheEntry create​(java.time.Instant requestInstant,
                                     java.time.Instant responseInstant,
                                     org.apache.hc.core5.http.HttpHost host,
                                     org.apache.hc.core5.http.HttpRequest request,
                                     org.apache.hc.core5.http.HttpResponse response,
                                     Resource resource)
        Create a new HttpCacheEntry with the given Resource.
        Parameters:
        requestInstant - Date/time when the request was made (Used for age calculations)
        responseInstant - Date/time that the response came back (Used for age calculations)
        host - Target host
        request - Original client request (a deep copy of this object is made)
        response - Origin response (a deep copy of this object is made)
        resource - Resource representing origin response body
      • createUpdated

        public HttpCacheEntry createUpdated​(java.time.Instant requestInstant,
                                            java.time.Instant responseInstant,
                                            org.apache.hc.core5.http.HttpHost host,
                                            org.apache.hc.core5.http.HttpRequest request,
                                            org.apache.hc.core5.http.HttpResponse response,
                                            HttpCacheEntry entry)
        Creates updated entry with the new information from the response. Should only be used for 304 responses.
        Parameters:
        requestInstant - Date/time when the request was made (Used for age calculations)
        responseInstant - Date/time that the response came back (Used for age calculations)
        host - Target host
        request - Original client request (a deep copy of this object is made)
        response - Origin response (a deep copy of this object is made)
        entry - Existing cache entry.