Class OkHeaders
- java.lang.Object
-
- com.squareup.okhttp.internal.http.OkHeaders
-
public final class OkHeaders extends Object
Headers and utilities for internal use by OkHttp.
-
-
Field Summary
Fields Modifier and Type Field Description static StringRECEIVED_MILLISSynthetic response header: the local time when the response was received.static StringSELECTED_PROTOCOLSynthetic response header: the selectedprotocol("spdy/3.1", "http/1.1", etc).static StringSENT_MILLISSynthetic response header: the local time when the request was sent.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddCookies(Request.Builder builder, Map<String,List<String>> cookieHeaders)static longcontentLength(Headers headers)static longcontentLength(Request request)static longcontentLength(Response response)static booleanhasVaryAll(Headers responseHeaders)Returns true if a Vary header contains an asterisk.static booleanhasVaryAll(Response response)Returns true if a Vary header contains an asterisk.static List<Challenge>parseChallenges(Headers responseHeaders, String challengeHeader)Parse RFC 2617 challenges.static RequestprocessAuthHeader(Authenticator authenticator, Response response, Proxy proxy)React to a failed authorization response by looking up new credentials.static Map<String,List<String>>toMultimap(Headers headers, String valueForNullKey)Returns an immutable map containing each field to its list of values.static Set<String>varyFields(Headers responseHeaders)Returns the names of the request headers that need to be checked for equality when caching.static HeadersvaryHeaders(Headers requestHeaders, Headers responseHeaders)Returns the subset of the headers inrequestHeadersthat impact the content of response's body.static HeadersvaryHeaders(Response response)Returns the subset of the headers inresponse's request that impact the content of response's body.static booleanvaryMatches(Response cachedResponse, Headers cachedRequest, Request newRequest)Returns true if none of the Vary headers have changed betweencachedRequestandnewRequest.
-
-
-
Method Detail
-
contentLength
public static long contentLength(Request request)
-
contentLength
public static long contentLength(Response response)
-
contentLength
public static long contentLength(Headers headers)
-
toMultimap
public static Map<String,List<String>> toMultimap(Headers headers, String valueForNullKey)
Returns an immutable map containing each field to its list of values.- Parameters:
valueForNullKey- the request line for requests, or the status line for responses. If non-null, this value is mapped to the null key.
-
addCookies
public static void addCookies(Request.Builder builder, Map<String,List<String>> cookieHeaders)
-
varyMatches
public static boolean varyMatches(Response cachedResponse, Headers cachedRequest, Request newRequest)
Returns true if none of the Vary headers have changed betweencachedRequestandnewRequest.
-
hasVaryAll
public static boolean hasVaryAll(Response response)
Returns true if a Vary header contains an asterisk. Such responses cannot be cached.
-
hasVaryAll
public static boolean hasVaryAll(Headers responseHeaders)
Returns true if a Vary header contains an asterisk. Such responses cannot be cached.
-
varyFields
public static Set<String> varyFields(Headers responseHeaders)
Returns the names of the request headers that need to be checked for equality when caching.
-
varyHeaders
public static Headers varyHeaders(Response response)
Returns the subset of the headers inresponse's request that impact the content of response's body.
-
varyHeaders
public static Headers varyHeaders(Headers requestHeaders, Headers responseHeaders)
Returns the subset of the headers inrequestHeadersthat impact the content of response's body.
-
parseChallenges
public static List<Challenge> parseChallenges(Headers responseHeaders, String challengeHeader)
Parse RFC 2617 challenges. This API is only interested in the scheme name and realm.
-
processAuthHeader
public static Request processAuthHeader(Authenticator authenticator, Response response, Proxy proxy) throws IOException
React to a failed authorization response by looking up new credentials. Returns a request for a subsequent attempt, or null if no further attempts should be made.- Throws:
IOException
-
-