Class ResponseHeaders
java.lang.Object
com.squareup.okhttp.internal.http.ResponseHeaders
public final class ResponseHeaders extends Object
Parsed HTTP response headers.
-
Constructor Summary
Constructors Constructor Description ResponseHeaders(URI uri, RawHeaders headers) -
Method Summary
Modifier and Type Method Description ResponseSourcechooseResponseSource(long nowMillis, RequestHeaders request)Returns the source to satisfyrequestgiven this cached response.ResponseHeaderscombine(ResponseHeaders network)Combines this cached header with a network header as defined by RFC 2616, 13.5.3.StringgetConnection()StringgetContentEncoding()intgetContentLength()StringgetEtag()DategetExpires()RawHeadersgetHeaders()DategetLastModified()intgetMaxAgeSeconds()DategetServedDate()intgetSMaxAgeSeconds()URIgetUri()Set<String>getVaryFields()booleanhasConnectionClose()booleanhasVaryAll()Returns true if a Vary header contains an asterisk.booleanisCacheable(RequestHeaders request)Returns true if this response can be stored to later serve another request.booleanisChunked()booleanisContentEncodingGzip()booleanisMustRevalidate()booleanisNoCache()booleanisNoStore()booleanisPublic()voidsetLocalTimestamps(long sentRequestMillis, long receivedResponseMillis)voidsetResponseSource(ResponseSource responseSource)voidsetTransport(String transport)voidstripContentEncoding()voidstripContentLength()booleanvalidate(ResponseHeaders networkResponse)Returns true if this cached response should be used; false if the network response should be used.booleanvaryMatches(Map<String,List<String>> cachedRequest, Map<String,List<String>> newRequest)Returns true if none of the Vary headers on this response have changed betweencachedRequestandnewRequest.
-
Constructor Details
-
ResponseHeaders
-
-
Method Details
-
isContentEncodingGzip
public boolean isContentEncodingGzip() -
stripContentEncoding
public void stripContentEncoding() -
stripContentLength
public void stripContentLength() -
isChunked
public boolean isChunked() -
hasConnectionClose
public boolean hasConnectionClose() -
getUri
-
getHeaders
-
getServedDate
-
getLastModified
-
getExpires
-
isNoCache
public boolean isNoCache() -
isNoStore
public boolean isNoStore() -
getMaxAgeSeconds
public int getMaxAgeSeconds() -
getSMaxAgeSeconds
public int getSMaxAgeSeconds() -
isPublic
public boolean isPublic() -
isMustRevalidate
public boolean isMustRevalidate() -
getEtag
-
getVaryFields
-
getContentEncoding
-
getContentLength
public int getContentLength() -
getConnection
-
setLocalTimestamps
public void setLocalTimestamps(long sentRequestMillis, long receivedResponseMillis) -
setResponseSource
-
setTransport
-
isCacheable
Returns true if this response can be stored to later serve another request. -
hasVaryAll
public boolean hasVaryAll()Returns true if a Vary header contains an asterisk. Such responses cannot be cached. -
varyMatches
public boolean varyMatches(Map<String,List<String>> cachedRequest, Map<String,List<String>> newRequest)Returns true if none of the Vary headers on this response have changed betweencachedRequestandnewRequest. -
chooseResponseSource
Returns the source to satisfyrequestgiven this cached response. -
validate
Returns true if this cached response should be used; false if the network response should be used. -
combine
Combines this cached header with a network header as defined by RFC 2616, 13.5.3.- Throws:
IOException
-