类 HttpHeaders

java.lang.Object
com.lark.oapi.okhttp.internal.http.HttpHeaders

public final class HttpHeaders extends Object
Headers and utilities for internal use by OkHttp.
  • 方法详细资料

    • 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 headerName)
      Parse RFC 7235 challenges. This is awkward because we need to look ahead to know how to interpret a token.

      For example, the first line has a parameter name/value pair and the second line has a single token68:

         
      
         WWW-Authenticate: Digest foo=bar
         WWW-Authenticate: Digest foo=
       

      Similarly, the first line has one challenge and the second line has two challenges:

         
      
         WWW-Authenticate: Digest ,foo=bar
         WWW-Authenticate: Digest ,foo
       
    • receiveHeaders

      public static void receiveHeaders(CookieJar cookieJar, HttpUrl url, Headers headers)
    • hasBody

      public static boolean hasBody(Response response)
      Returns true if the response must have a (possibly 0-length) body. See RFC 7231.
    • skipUntil

      public static int skipUntil(String input, int pos, String characters)
      Returns the next index in input at or after pos that contains a character from characters. Returns the input length if none of the requested characters can be found.
    • skipWhitespace

      public static int skipWhitespace(String input, int pos)
      Returns the next non-whitespace character in input that is white space. Result is undefined if input contains newline characters.
    • parseSeconds

      public static int parseSeconds(String value, int defaultValue)
      Returns value as a positive integer, or 0 if it is negative, or defaultValue if it cannot be parsed.