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).
      • RESPONSE_SOURCE

        public static final String RESPONSE_SOURCE
        Synthetic response header: the location from which the response was loaded.
    • Method Detail

      • contentLength

        public static long contentLength(Request request)
      • contentLength

        public static long contentLength(Response response)
      • contentLength

        public static long contentLength(Headers headers)
      • 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.