public final class CacheInterceptor extends java.lang.Object implements Interceptor
Interceptor.Chain
Modifier and Type | Field and Description |
---|---|
(package private) InternalCache |
cache |
Constructor and Description |
---|
CacheInterceptor(InternalCache cache) |
Modifier and Type | Method and Description |
---|---|
private Response |
cacheWritingResponse(CacheRequest cacheRequest,
Response response)
Returns a new source that writes bytes to
cacheRequest as they are read by the source
consumer. |
private static Headers |
combine(Headers cachedHeaders,
Headers networkHeaders)
Combines cached headers with a network headers as defined by RFC 7234, 4.3.4.
|
Response |
intercept(Interceptor.Chain chain) |
(package private) static boolean |
isContentSpecificHeader(java.lang.String fieldName)
Returns true if
fieldName is content specific and therefore should always be used
from cached headers. |
(package private) static boolean |
isEndToEnd(java.lang.String fieldName)
Returns true if
fieldName is an end-to-end HTTP header, as defined by RFC 2616,
13.5.1. |
private static Response |
stripBody(Response response) |
final InternalCache cache
public CacheInterceptor(InternalCache cache)
public Response intercept(Interceptor.Chain chain) throws java.io.IOException
intercept
in interface Interceptor
java.io.IOException
private Response cacheWritingResponse(CacheRequest cacheRequest, Response response) throws java.io.IOException
cacheRequest
as they are read by the source
consumer. This is careful to discard bytes left over when the stream is closed; otherwise we
may never exhaust the source stream and therefore not complete the cached response.java.io.IOException
private static Headers combine(Headers cachedHeaders, Headers networkHeaders)
static boolean isEndToEnd(java.lang.String fieldName)
fieldName
is an end-to-end HTTP header, as defined by RFC 2616,
13.5.1.static boolean isContentSpecificHeader(java.lang.String fieldName)
fieldName
is content specific and therefore should always be used
from cached headers.