@Contract(threading=IMMUTABLE) public class HttpCacheEntry extends Object implements org.apache.hc.core5.http.MessageHeaders, Serializable
HttpResponse
in a cache.
Some entries can optionally depend on system resources that may require
explicit deallocation. In such a case getResource()
should return
a non null instance of Resource
that must be deallocated by calling
Resource.dispose()
method when no longer used.Constructor and Description |
---|
HttpCacheEntry(Date requestDate,
Date responseDate,
int status,
org.apache.hc.core5.http.Header[] responseHeaders,
Resource resource)
Deprecated.
|
HttpCacheEntry(Date requestDate,
Date responseDate,
int status,
org.apache.hc.core5.http.Header[] responseHeaders,
Resource resource,
Map<String,String> variantMap)
Deprecated.
|
HttpCacheEntry(Instant requestDate,
Instant responseDate,
int status,
org.apache.hc.core5.http.Header[] responseHeaders,
Resource resource)
Deprecated.
|
HttpCacheEntry(Instant requestDate,
Instant responseDate,
int status,
org.apache.hc.core5.http.Header[] responseHeaders,
Resource resource,
Map<String,String> variantMap)
Deprecated.
|
HttpCacheEntry(Instant requestDate,
Instant responseDate,
String method,
String requestURI,
org.apache.hc.core5.http.message.HeaderGroup requestHeaders,
int status,
org.apache.hc.core5.http.message.HeaderGroup responseHeaders,
Resource resource,
Collection<String> variants)
Internal constructor that makes no validation of the input parameters and makes
no copies of the original client request and the origin response.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsHeader(String name) |
int |
countHeaders(String name) |
Date |
getDate()
Gets the Date value of the "Date" header or null if the header is missing or cannot be
parsed.
|
ETag |
getETag() |
Instant |
getExpires() |
org.apache.hc.core5.http.Header |
getFirstHeader(String name)
Returns the first header from the origin response with the given
name.
|
org.apache.hc.core5.http.Header |
getHeader(String name) |
org.apache.hc.core5.http.Header[] |
getHeaders()
Returns all the headers that were on the origin response.
|
org.apache.hc.core5.http.Header[] |
getHeaders(String name)
Gets all the headers with the given name that were on the origin
response.
|
Instant |
getInstant() |
org.apache.hc.core5.http.Header |
getLastHeader(String name) |
Instant |
getLastModified() |
Date |
getRequestDate()
Deprecated.
|
Instant |
getRequestInstant()
Returns the time the associated origin request was initiated by the
caching module.
|
String |
getRequestMethod()
Returns the HTTP request method that was used to create the cached
response entry.
|
String |
getRequestURI() |
Resource |
getResource()
Returns the
Resource containing the origin response body. |
Date |
getResponseDate()
Deprecated.
|
Instant |
getResponseInstant()
Returns the time the origin response was received by the caching module.
|
int |
getStatus()
Returns the status from the origin
HttpResponse . |
Map<String,String> |
getVariantMap()
Deprecated.
No longer applicable. Use
getVariants() instead. |
Set<String> |
getVariants()
Returns all known variants.
|
boolean |
hasVariants()
Indicates whether the origin response indicated the associated
resource had variants (i.e.
|
Iterator<org.apache.hc.core5.http.Header> |
headerIterator() |
Iterator<org.apache.hc.core5.http.Header> |
headerIterator(String name) |
static boolean |
isNewer(HttpCacheEntry entry,
org.apache.hc.core5.http.MessageHeaders message)
Tests if the given
HttpCacheEntry is newer than the given MessageHeaders
by comparing values of their DATE header. |
Iterator<org.apache.hc.core5.http.Header> |
requestHeaderIterator() |
Iterator<org.apache.hc.core5.http.Header> |
requestHeaderIterator(String headerName) |
org.apache.hc.core5.http.MessageHeaders |
requestHeaders() |
org.apache.hc.core5.http.MessageHeaders |
responseHeaders() |
String |
toString()
Provides a string representation of this instance suitable for
human consumption.
|
@Internal public HttpCacheEntry(Instant requestDate, Instant responseDate, String method, String requestURI, org.apache.hc.core5.http.message.HeaderGroup requestHeaders, int status, org.apache.hc.core5.http.message.HeaderGroup responseHeaders, Resource resource, Collection<String> variants)
@Deprecated public HttpCacheEntry(Date requestDate, Date responseDate, int status, org.apache.hc.core5.http.Header[] responseHeaders, Resource resource, Map<String,String> variantMap)
HttpCacheEntryFactory
HttpCacheEntry
with variants.requestDate
- Date/time when the request was made (Used for age
calculations)responseDate
- Date/time that the response came back (Used for age
calculations)status
- HTTP status from origin responseresponseHeaders
- Header[] from original HTTP Responseresource
- representing origin response bodyvariantMap
- 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)@Deprecated public HttpCacheEntry(Instant requestDate, Instant responseDate, int status, org.apache.hc.core5.http.Header[] responseHeaders, Resource resource, Map<String,String> variantMap)
HttpCacheEntryFactory
HttpCacheEntry
with variants.requestDate
- Date/time when the request was made (Used for age calculations)responseDate
- Date/time that the response came back (Used for age calculations)status
- HTTP status from origin responseresponseHeaders
- Header[] from original HTTP Responseresource
- representing origin response bodyvariantMap
- 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)@Deprecated public HttpCacheEntry(Date requestDate, Date responseDate, int status, org.apache.hc.core5.http.Header[] responseHeaders, Resource resource)
HttpCacheEntryFactory
HttpCacheEntry
.requestDate
- Date/time when the request was made (Used for age calculations)responseDate
- Date/time that the response came back (Used for age calculations)status
- HTTP status from origin responseresponseHeaders
- Header[] from original HTTP Responseresource
- representing origin response body@Deprecated public HttpCacheEntry(Instant requestDate, Instant responseDate, int status, org.apache.hc.core5.http.Header[] responseHeaders, Resource resource)
HttpCacheEntryFactory
HttpCacheEntry
.requestDate
- Date/time when the request was made (Used for age
calculations)responseDate
- Date/time that the response came back (Used for age
calculations)status
- HTTP status from origin responseresponseHeaders
- Header[] from original HTTP Responseresource
- representing origin response bodypublic int getStatus()
HttpResponse
.@Deprecated public Date getRequestDate()
getRequestInstant()
Date
public Instant getRequestInstant()
Instant
@Deprecated public Date getResponseDate()
getResponseInstant()
Date
public Instant getResponseInstant()
Instant
public org.apache.hc.core5.http.Header[] getHeaders()
getHeaders
in interface org.apache.hc.core5.http.MessageHeaders
public org.apache.hc.core5.http.Header getFirstHeader(String name)
getFirstHeader
in interface org.apache.hc.core5.http.MessageHeaders
public org.apache.hc.core5.http.Header getLastHeader(String name)
getLastHeader
in interface org.apache.hc.core5.http.MessageHeaders
public org.apache.hc.core5.http.Header[] getHeaders(String name)
getHeaders
in interface org.apache.hc.core5.http.MessageHeaders
public boolean containsHeader(String name)
containsHeader
in interface org.apache.hc.core5.http.MessageHeaders
public int countHeaders(String name)
countHeaders
in interface org.apache.hc.core5.http.MessageHeaders
public org.apache.hc.core5.http.Header getHeader(String name) throws org.apache.hc.core5.http.ProtocolException
getHeader
in interface org.apache.hc.core5.http.MessageHeaders
org.apache.hc.core5.http.ProtocolException
public Iterator<org.apache.hc.core5.http.Header> headerIterator()
headerIterator
in interface org.apache.hc.core5.http.MessageHeaders
public Iterator<org.apache.hc.core5.http.Header> headerIterator(String name)
headerIterator
in interface org.apache.hc.core5.http.MessageHeaders
public org.apache.hc.core5.http.MessageHeaders responseHeaders()
public Date getDate()
public Instant getInstant()
public Instant getExpires()
public Instant getLastModified()
public ETag getETag()
public boolean hasVariants()
@Deprecated public Map<String,String> getVariantMap()
getVariants()
instead.public String getRequestMethod()
public String getRequestURI()
public org.apache.hc.core5.http.MessageHeaders requestHeaders()
public Iterator<org.apache.hc.core5.http.Header> requestHeaderIterator()
public Iterator<org.apache.hc.core5.http.Header> requestHeaderIterator(String headerName)
public static boolean isNewer(HttpCacheEntry entry, org.apache.hc.core5.http.MessageHeaders message)
HttpCacheEntry
is newer than the given MessageHeaders
by comparing values of their DATE header. In case the given entry, or the message,
or their DATE headers are null, this method returns false
.Copyright © 2010–2021 The Apache Software Foundation. All rights reserved.