Class ConditionalRequestBuilder<T extends org.apache.hc.core5.http.HttpRequest>


  • class ConditionalRequestBuilder<T extends org.apache.hc.core5.http.HttpRequest>
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.apache.hc.core5.function.Factory<T,​T> messageCopier  
    • Constructor Summary

      Constructors 
      Constructor Description
      ConditionalRequestBuilder​(org.apache.hc.core5.function.Factory<T,​T> messageCopier)  
    • Field Detail

      • messageCopier

        private final org.apache.hc.core5.function.Factory<T extends org.apache.hc.core5.http.HttpRequest,​T extends org.apache.hc.core5.http.HttpRequest> messageCopier
    • Constructor Detail

      • ConditionalRequestBuilder

        ConditionalRequestBuilder​(org.apache.hc.core5.function.Factory<T,​T> messageCopier)
    • Method Detail

      • buildConditionalRequest

        public T buildConditionalRequest​(T request,
                                         HttpCacheEntry cacheEntry)
        When a HttpCacheEntry is stale but 'might' be used as a response to an HttpRequest we will attempt to revalidate the entry with the origin. Build the origin HttpRequest here and return it.
        Parameters:
        request - the original request from the caller
        cacheEntry - the entry that needs to be re-validated
        Returns:
        the wrapped request
      • buildConditionalRequestFromVariants

        public T buildConditionalRequestFromVariants​(T request,
                                                     java.util.Map<java.lang.String,​Variant> variants)
        When a HttpCacheEntry does not exist for a specific HttpRequest we attempt to see if an existing HttpCacheEntry is appropriate by building a conditional HttpRequest using the variants' ETag values. If no such values exist, the request is unmodified
        Parameters:
        request - the original request from the caller
        variants -
        Returns:
        the wrapped request
      • buildUnconditionalRequest

        public T buildUnconditionalRequest​(T request)
        Returns a request to unconditionally validate a cache entry with the origin. In certain cases (due to multiple intervening caches) our cache may actually receive a response to a normal conditional validation where the Date header is actually older than that of our current cache entry. In this case, the protocol recommendation is to retry the validation and force syncup with the origin.
        Parameters:
        request - client request we are trying to satisfy
        Returns:
        an unconditional validation request