org.apache.http.impl.client.cache
Class CacheEntry

java.lang.Object
  extended by org.apache.http.impl.client.cache.CacheEntry
All Implemented Interfaces:
Serializable

@Immutable
public class CacheEntry
extends Object
implements Serializable

Structure used to store an HttpResponse in a cache

Since:
4.1
See Also:
Serialized Form

Field Summary
static long MAX_AGE
           
 
Constructor Summary
CacheEntry(Date requestDate, Date responseDate, ProtocolVersion version, Header[] responseHeaders, HttpEntity body, int status, String reason)
          Create a new CacheEntry
 
Method Summary
 CacheEntry addVariantURI(String variantURI)
           
protected  boolean contentLengthHeaderMatchesActualLength()
          This matters for deciding whether the cache entry is valid to serve as a response.
protected  long getAgeValue()
           
 Header[] getAllHeaders()
           
protected  long getApparentAgeSecs()
           
 HttpEntity getBody()
           
protected  long getContentLengthValue()
           
protected  long getCorrectedInitialAgeSecs()
           
protected  long getCorrectedReceivedAgeSecs()
           
 long getCurrentAgeSecs()
           
protected  Date getCurrentDate()
           
protected  Date getDateValue()
           
protected  Date getExpirationDate()
           
 Header getFirstHeader(String name)
           
 long getFreshnessLifetimeSecs()
           
 Header[] getHeaders(String name)
           
protected  long getMaxAge()
           
 ProtocolVersion getProtocolVersion()
           
 String getReasonPhrase()
           
 Date getRequestDate()
           
protected  long getResidentTimeSecs()
           
 Date getResponseDate()
           
protected  long getResponseDelaySecs()
           
 int getStatusCode()
           
 Set<String> getVariantURIs()
           
protected  boolean hasCacheControlDirective(String directive)
           
 boolean hasVariants()
           
 boolean isResponseFresh()
           
 boolean isRevalidatable()
           
 boolean modifiedSince(HttpRequest request)
           
 boolean mustRevalidate()
           
 boolean proxyRevalidate()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_AGE

public static final long MAX_AGE
See Also:
Constant Field Values
Constructor Detail

CacheEntry

public CacheEntry(Date requestDate,
                  Date responseDate,
                  ProtocolVersion version,
                  Header[] responseHeaders,
                  HttpEntity body,
                  int status,
                  String reason)
Create a new CacheEntry

Parameters:
requestDate - Date/time when the request was made (Used for age calculations)
responseDate - Date/time that the response came back (Used for age calculations)
version - HTTP Response Version
responseHeaders - Header[] from original HTTP Response
body - HttpEntity representing the body of the response
status - Numeric HTTP Status Code
reason - String message from HTTP Status Line
Method Detail

addVariantURI

public CacheEntry addVariantURI(String variantURI)

getProtocolVersion

public ProtocolVersion getProtocolVersion()

getReasonPhrase

public String getReasonPhrase()

getStatusCode

public int getStatusCode()

getRequestDate

public Date getRequestDate()

getResponseDate

public Date getResponseDate()

getBody

public HttpEntity getBody()

getAllHeaders

public Header[] getAllHeaders()

getFirstHeader

public Header getFirstHeader(String name)

getHeaders

public Header[] getHeaders(String name)

getDateValue

protected Date getDateValue()

getContentLengthValue

protected long getContentLengthValue()

contentLengthHeaderMatchesActualLength

protected boolean contentLengthHeaderMatchesActualLength()
This matters for deciding whether the cache entry is valid to serve as a response. If these values do not match, we might have a partial response

Returns:
boolean indicating whether actual length matches Content-Length

getApparentAgeSecs

protected long getApparentAgeSecs()

getAgeValue

protected long getAgeValue()

getCorrectedReceivedAgeSecs

protected long getCorrectedReceivedAgeSecs()

getResponseDelaySecs

protected long getResponseDelaySecs()

getCorrectedInitialAgeSecs

protected long getCorrectedInitialAgeSecs()

getCurrentDate

protected Date getCurrentDate()

getResidentTimeSecs

protected long getResidentTimeSecs()

getCurrentAgeSecs

public long getCurrentAgeSecs()

getMaxAge

protected long getMaxAge()

getExpirationDate

protected Date getExpirationDate()

getFreshnessLifetimeSecs

public long getFreshnessLifetimeSecs()

isResponseFresh

public boolean isResponseFresh()

isRevalidatable

public boolean isRevalidatable()
Returns:
boolean indicating whether ETag or Last-Modified responseHeaders are present

modifiedSince

public boolean modifiedSince(HttpRequest request)

hasVariants

public boolean hasVariants()
Returns:
boolean indicating whether any Vary responseHeaders are present

getVariantURIs

public Set<String> getVariantURIs()

toString

public String toString()
Overrides:
toString in class Object

hasCacheControlDirective

protected boolean hasCacheControlDirective(String directive)

mustRevalidate

public boolean mustRevalidate()

proxyRevalidate

public boolean proxyRevalidate()


Copyright © 1999-2010 Apache Software Foundation. All Rights Reserved.