Package org.microproxy.cache
Class CachedResponse
java.lang.Object
org.microproxy.cache.CachedResponse
A stored response: status, header fields and body as received, the request header values its
Vary named, and when it was requested and received (for the age calculation of RFC 9111
section 4.2.3). Instances are immutable.-
Constructor Summary
ConstructorsConstructorDescriptionCachedResponse(String key, Map<String, String> vary, int status, String reason, HttpHeaders headers, byte[] body, long requestTime, long responseTime) Creates a stored response and its freshness metadata. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]body()Returns a copy of the body.headers()Returns a copy of the stored header fields.key()Returns the URL identifying this cached response.reason()Returns the stored HTTP reason phrase.longReturns when the request was sent, in epoch milliseconds.longReturns when the response was received, in epoch milliseconds.intstatus()Returns the stored HTTP status code.toString()vary()Returns the request header values selecting this cached variant.longweight()Returns roughly how much memory or disk the entry takes.
-
Constructor Details
-
CachedResponse
public CachedResponse(String key, Map<String, String> vary, int status, String reason, HttpHeaders headers, byte[] body, long requestTime, long responseTime) Creates a stored response and its freshness metadata.- Parameters:
key- the URL the response was stored undervary- for each field named byVary(lower-cased), the request's normalized value, ornullif the request lacked itstatus- the HTTP status codereason- the HTTP reason phraseheaders- the response header fieldsbody- the response body bytesrequestTime- the request timestamp in epoch millisecondsresponseTime- the response timestamp in epoch milliseconds
-
-
Method Details
-
key
Returns the URL identifying this cached response.- Returns:
- the URL identifying this cached response
-
vary
Returns the request header values selecting this cached variant.- Returns:
- the request header values selecting this cached variant
-
status
public int status()Returns the stored HTTP status code.- Returns:
- the stored HTTP status code
-
reason
Returns the stored HTTP reason phrase.- Returns:
- the stored HTTP reason phrase
-
headers
Returns a copy of the stored header fields.- Returns:
- a copy of the stored header fields
-
body
public byte[] body()Returns a copy of the body.- Returns:
- a copy of the body
-
requestTime
public long requestTime()Returns when the request was sent, in epoch milliseconds.- Returns:
- when the request was sent, in epoch milliseconds
-
responseTime
public long responseTime()Returns when the response was received, in epoch milliseconds.- Returns:
- when the response was received, in epoch milliseconds
-
weight
public long weight()Returns roughly how much memory or disk the entry takes.- Returns:
- roughly how much memory or disk the entry takes
-
toString
-