@Contract(threading=IMMUTABLE)
public class HttpCacheEntry
extends java.lang.Object
implements java.io.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.Modifier and Type | Field and Description |
---|---|
private java.util.Date |
date |
private static java.lang.String |
REQUEST_METHOD_HEADER_NAME |
private java.util.Date |
requestDate |
private Resource |
resource |
private java.util.Date |
responseDate |
private org.apache.http.message.HeaderGroup |
responseHeaders |
private static long |
serialVersionUID |
private org.apache.http.StatusLine |
statusLine |
private java.util.Map<java.lang.String,java.lang.String> |
variantMap |
Constructor and Description |
---|
HttpCacheEntry(java.util.Date requestDate,
java.util.Date responseDate,
org.apache.http.StatusLine statusLine,
org.apache.http.Header[] responseHeaders,
Resource resource)
Create a new
HttpCacheEntry . |
HttpCacheEntry(java.util.Date requestDate,
java.util.Date responseDate,
org.apache.http.StatusLine statusLine,
org.apache.http.Header[] responseHeaders,
Resource resource,
java.util.Map<java.lang.String,java.lang.String> variantMap)
Create a new
HttpCacheEntry with variants. |
HttpCacheEntry(java.util.Date requestDate,
java.util.Date responseDate,
org.apache.http.StatusLine statusLine,
org.apache.http.Header[] responseHeaders,
Resource resource,
java.util.Map<java.lang.String,java.lang.String> variantMap,
java.lang.String requestMethod)
Create a new
HttpCacheEntry with variants. |
HttpCacheEntry(java.util.Date requestDate,
java.util.Date responseDate,
org.apache.http.StatusLine statusLine,
org.apache.http.Header[] responseHeaders,
Resource resource,
java.lang.String requestMethod)
Create a new
HttpCacheEntry . |
Modifier and Type | Method and Description |
---|---|
org.apache.http.Header[] |
getAllHeaders()
Returns all the headers that were on the origin response.
|
java.util.Date |
getDate()
Gets the Date value of the "Date" header or null if the header is missing or cannot be
parsed.
|
org.apache.http.Header |
getFirstHeader(java.lang.String name)
Returns the first header from the origin response with the given
name.
|
org.apache.http.Header[] |
getHeaders(java.lang.String name)
Gets all the headers with the given name that were on the origin
response.
|
org.apache.http.ProtocolVersion |
getProtocolVersion()
Returns the
ProtocolVersion from the origin
HttpResponse . |
java.lang.String |
getReasonPhrase()
Gets the reason phrase from the origin
HttpResponse , for example, "Not Modified". |
java.util.Date |
getRequestDate()
Returns the time the associated origin request was initiated by the
caching module.
|
java.lang.String |
getRequestMethod()
Returns the HTTP request method that was used to create the cached
response entry.
|
Resource |
getResource()
Returns the
Resource containing the origin response body. |
java.util.Date |
getResponseDate()
Returns the time the origin response was received by the caching module.
|
int |
getStatusCode()
Returns the HTTP response code from the origin
HttpResponse . |
org.apache.http.StatusLine |
getStatusLine()
Returns the
StatusLine from the origin
HttpResponse . |
java.util.Map<java.lang.String,java.lang.String> |
getVariantMap()
Returns an index about where in the cache different variants for
a given resource are stored.
|
boolean |
hasVariants()
Indicates whether the origin response indicated the associated
resource had variants (i.e.
|
private java.util.Date |
parseDate()
Find the "Date" response header and parse it into a java.util.Date
|
java.lang.String |
toString()
Provides a string representation of this instance suitable for
human consumption.
|
private static final long serialVersionUID
private static final java.lang.String REQUEST_METHOD_HEADER_NAME
private final java.util.Date requestDate
private final java.util.Date responseDate
private final org.apache.http.StatusLine statusLine
private final org.apache.http.message.HeaderGroup responseHeaders
private final Resource resource
private final java.util.Map<java.lang.String,java.lang.String> variantMap
private final java.util.Date date
public HttpCacheEntry(java.util.Date requestDate, java.util.Date responseDate, org.apache.http.StatusLine statusLine, org.apache.http.Header[] responseHeaders, Resource resource, java.util.Map<java.lang.String,java.lang.String> variantMap, java.lang.String requestMethod)
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)statusLine
- HTTP status line 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)requestMethod
- HTTP method used when the request was madepublic HttpCacheEntry(java.util.Date requestDate, java.util.Date responseDate, org.apache.http.StatusLine statusLine, org.apache.http.Header[] responseHeaders, Resource resource, java.util.Map<java.lang.String,java.lang.String> variantMap)
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)statusLine
- HTTP status line 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)public HttpCacheEntry(java.util.Date requestDate, java.util.Date responseDate, org.apache.http.StatusLine statusLine, org.apache.http.Header[] responseHeaders, Resource resource)
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)statusLine
- HTTP status line from origin responseresponseHeaders
- Header[] from original HTTP Responseresource
- representing origin response bodypublic HttpCacheEntry(java.util.Date requestDate, java.util.Date responseDate, org.apache.http.StatusLine statusLine, org.apache.http.Header[] responseHeaders, Resource resource, java.lang.String requestMethod)
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)statusLine
- HTTP status line from origin responseresponseHeaders
- Header[] from original HTTP Responseresource
- representing origin response bodyrequestMethod
- HTTP method used when the request was madeprivate java.util.Date parseDate()
public org.apache.http.StatusLine getStatusLine()
StatusLine
from the origin
HttpResponse
.public org.apache.http.ProtocolVersion getProtocolVersion()
ProtocolVersion
from the origin
HttpResponse
.public java.lang.String getReasonPhrase()
HttpResponse
, for example, "Not Modified".public int getStatusCode()
HttpResponse
.public java.util.Date getRequestDate()
Date
public java.util.Date getResponseDate()
Date
public org.apache.http.Header[] getAllHeaders()
public org.apache.http.Header getFirstHeader(java.lang.String name)
public org.apache.http.Header[] getHeaders(java.lang.String name)
public java.util.Date getDate()
public boolean hasVariants()
true
if this cached response was a variantpublic java.util.Map<java.lang.String,java.lang.String> getVariantMap()
HttpCacheStorage
where that
particular variant is stored. The first variant returned is used as
the "parent" entry to hold this index of the other variants.public java.lang.String getRequestMethod()
public java.lang.String toString()
toString
in class java.lang.Object