Class OkHeaders


  • public final class OkHeaders
    extends Object
    Headers and utilities for internal use by OkHttp.
    • Field Detail

      • SENT_MILLIS

        public static final String SENT_MILLIS
        Synthetic response header: the local time when the request was sent.
      • RECEIVED_MILLIS

        public static final String RECEIVED_MILLIS
        Synthetic response header: the local time when the response was received.
      • SELECTED_PROTOCOL

        public static final String SELECTED_PROTOCOL
        Synthetic response header: the selected protocol ("spdy/3.1", "http/1.1", etc).
    • 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.
      • varyMatches

        public static boolean varyMatches​(Response cachedResponse,
                                          Headers cachedRequest,
                                          Request newRequest)
        Returns true if none of the Vary headers have changed between cachedRequest and newRequest.
      • 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 in response'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 in requestHeaders that 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