Modifier and Type | Field and Description |
---|---|
static CacheKeyGenerator |
INSTANCE
Default instance of
CacheKeyGenerator . |
Constructor and Description |
---|
CacheKeyGenerator() |
Modifier and Type | Method and Description |
---|---|
String |
generateKey(org.apache.hc.core5.http.HttpHost host,
org.apache.hc.core5.http.HttpRequest request)
Computes a root key for the given
HttpHost and HttpRequest
that can be used as a unique identifier for cached resources. |
String |
generateKey(org.apache.hc.core5.http.HttpHost host,
org.apache.hc.core5.http.HttpRequest request,
HttpCacheEntry entry)
Deprecated.
|
String |
generateKey(URI requestUri)
Computes a key for the given request
URI that can be used as
a unique identifier for cached resources. |
String |
generateVariantKey(org.apache.hc.core5.http.HttpRequest request,
Collection<String> variantNames)
Computes a "variant key" for the given request and the given variants.
|
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 (
Vary header is present). |
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 given
HttpRequest . |
static URI |
normalize(String requestUri)
Lenient URI parser that normalizes valid
URI s and returns null for malformed URIs. |
static URI |
normalize(URI requestUri)
Returns normalized representation of the request URI optimized for use as a cache key.
|
static void |
normalizeElements(Iterator<org.apache.hc.core5.http.Header> iterator,
Consumer<String> consumer) |
static void |
normalizeElements(org.apache.hc.core5.http.MessageHeaders message,
String headerName,
Consumer<String> consumer) |
String |
resolve(URI uri) |
static List<String> |
variantNames(org.apache.hc.core5.http.MessageHeaders message)
Returns all variant names contained in VARY headers of the given message.
|
public static final CacheKeyGenerator INSTANCE
CacheKeyGenerator
.@Internal public static String getRequestUri(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request)
HttpRequest
.
This method will use HttpRequest.getPath()
, HttpRequest.getScheme()
and
HttpRequest.getAuthority()
values when available or attributes of target
HttpHost
in order to construct an absolute URI.
This method will not attempt to ensure validity of the resultant text representation.
target
- target hostrequest
- the HttpRequest
@Internal public static URI normalize(URI requestUri) throws URISyntaxException
URISyntaxException
@Internal public static URI normalize(String requestUri)
URI
s and returns null
for malformed URIs.public String generateKey(URI requestUri)
URI
that can be used as
a unique identifier for cached resources. The URI is expected to
in an absolute form.requestUri
- request URIpublic String generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)
HttpHost
and HttpRequest
that can be used as a unique identifier for cached resources.host
- The host for this requestrequest
- the HttpRequest
public static List<String> variantNames(org.apache.hc.core5.http.MessageHeaders message)
@Internal public static void normalizeElements(org.apache.hc.core5.http.MessageHeaders message, String headerName, Consumer<String> consumer)
@Internal public static void normalizeElements(Iterator<org.apache.hc.core5.http.Header> iterator, Consumer<String> consumer)
public String generateVariantKey(org.apache.hc.core5.http.HttpRequest request, Collection<String> variantNames)
request
- originating requestvariantNames
- variant namespublic String generateVariantKey(org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
Vary
header is present).request
- originating requestentry
- cache entrynull
otherwise.@Deprecated public String generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
generateKey(HttpHost, HttpRequest)
or generateVariantKey(HttpRequest, Collection)
HttpHost
and HttpRequest
that can be used as a unique identifier for cached resources. if the request has a
VARY header the identifier will also include variant key.host
- The host for this requestrequest
- the HttpRequest
entry
- the parent entry used to track the variantsCopyright © 1999–2021 The Apache Software Foundation. All rights reserved.