Class CacheKeyGenerator
java.lang.Object
org.apache.hc.client5.http.impl.cache.CacheKeyGenerator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CacheKeyGeneratorDefault instance ofCacheKeyGenerator. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateKey(URI requestUri) Computes a key for the given requestURIthat can be used as a unique identifier for cached resources.generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request) Computes a root key for the givenHttpHostandHttpRequestthat can be used as a unique identifier for cached resources.generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) Deprecated.generateVariantKey(org.apache.hc.core5.http.HttpRequest request, Collection<String> variantNames) Computes a "variant key" for the given request and the given variants.generateVariantKey(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) Computes a "variant key" from the headers of the given request if the given cache entry can have variants (Varyheader is present).static StringgetRequestUri(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) Returns text representation of the request URI of the givenHttpRequest.static URILenient URI parser that normalizes validURIs and returnsnullfor malformed URIs.static URIReturns normalized representation of the request URI optimized for use as a cache key.static voidnormalizeElements(Iterator<org.apache.hc.core5.http.Header> iterator, Consumer<String> consumer) static voidnormalizeElements(org.apache.hc.core5.http.MessageHeaders message, String headerName, Consumer<String> consumer) variantNames(org.apache.hc.core5.http.MessageHeaders message) Returns all variant names contained in VARY headers of the given message.
-
Field Details
-
INSTANCE
Default instance ofCacheKeyGenerator.
-
-
Constructor Details
-
CacheKeyGenerator
public CacheKeyGenerator()
-
-
Method Details
-
resolve
-
getRequestUri
@Internal public static String getRequestUri(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request) Returns text representation of the request URI of the givenHttpRequest. This method will useHttpRequest.getPath(),HttpRequest.getScheme()andHttpRequest.getAuthority()values when available or attributes of targetHttpHostin order to construct an absolute URI.This method will not attempt to ensure validity of the resultant text representation.
- Parameters:
target- target hostrequest- theHttpRequest- Returns:
- String the request URI
-
normalize
Returns normalized representation of the request URI optimized for use as a cache key. This method ensures the resultant URI has an explicit port in the authority component, and explicit path component and no fragment.- Throws:
URISyntaxException
-
normalize
-
generateKey
-
generateKey
public String generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request) Computes a root key for the givenHttpHostandHttpRequestthat can be used as a unique identifier for cached resources.- Parameters:
host- The host for this requestrequest- theHttpRequest- Returns:
- cache key
-
variantNames
-
normalizeElements
-
normalizeElements
-
generateVariantKey
public String generateVariantKey(org.apache.hc.core5.http.HttpRequest request, Collection<String> variantNames) Computes a "variant key" for the given request and the given variants.- Parameters:
request- originating requestvariantNames- variant names- Returns:
- variant key
- Since:
- 5.4
-
generateVariantKey
public String generateVariantKey(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) Computes a "variant key" from the headers of the given request if the given cache entry can have variants (Varyheader is present).- Parameters:
request- originating requestentry- cache entry- Returns:
- variant key if the given cache entry can have variants,
nullotherwise.
-
generateKey
@Deprecated public String generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry) Deprecated.Computes a key for the givenHttpHostandHttpRequestthat can be used as a unique identifier for cached resources. if the request has a VARY header the identifier will also include variant key.- Parameters:
host- The host for this requestrequest- theHttpRequestentry- the parent entry used to track the variants- Returns:
- cache key
-
generateKey(HttpHost, HttpRequest)orgenerateVariantKey(HttpRequest, Collection)