Package 

Class HttpHeaders


  • 
    public final class HttpHeaders
    
                        

    Headers and utilities for internal use by OkHttp.

    • Method Summary

      Modifier and Type Method Description
      static long contentLength(MobonResponse mobonResponse)
      static long contentLength(Headers headers)
      static boolean varyMatches(MobonResponse cachedMobonResponse, Headers cachedRequest, MobonRequest newMobonRequest) Returns true if none of the Vary headers have changed between {@code cachedRequest} and {@code * newMobonRequest}.
      static boolean hasVaryAll(MobonResponse mobonResponse) Returns true if a Vary header contains an asterisk.
      static boolean hasVaryAll(Headers responseHeaders) Returns true if a Vary header contains an asterisk.
      static Set<String> varyFields(Headers responseHeaders) Returns the names of the request headers that need to be checked for equality when caching.
      static Headers varyHeaders(MobonResponse mobonResponse) Returns the subset of the headers in {@code mobonResponse}'s request that impact the content ofmobonResponse's body.
      static Headers varyHeaders(Headers requestHeaders, Headers responseHeaders) Returns the subset of the headers in {@code requestHeaders} that impact the content ofresponse's body.
      static List<Challenge> parseChallenges(Headers responseHeaders, String challengeHeader) Parse RFC 7617 challenges, also wrong ordered ones.This API is only interested in the scheme name and realm.
      static void receiveHeaders(CookieJar cookieJar, HttpUrl url, Headers headers)
      static boolean hasBody(MobonResponse mobonResponse) Returns true if the mobonResponse must have a (possibly 0-length) body.
      static int skipUntil(String input, int pos, String characters) Returns the next index in {@code input} at or after {@code pos} that contains a character from {@code characters}.
      static int skipWhitespace(String input, int pos) Returns the next non-whitespace character in {@code input} that is white space.
      static int parseSeconds(String value, int defaultValue) Returns {@code value} as a positive integer, or 0 if it is negative, or {@code defaultValue} ifit cannot be parsed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • varyMatches

         static boolean varyMatches(MobonResponse cachedMobonResponse, Headers cachedRequest, MobonRequest newMobonRequest)

        Returns true if none of the Vary headers have changed between {@code cachedRequest} and {@code * newMobonRequest}.

      • hasVaryAll

         static boolean hasVaryAll(MobonResponse mobonResponse)

        Returns true if a Vary header contains an asterisk. Such responses cannot be cached.

      • hasVaryAll

         static boolean hasVaryAll(Headers responseHeaders)

        Returns true if a Vary header contains an asterisk. Such responses cannot be cached.

      • varyFields

         static Set<String> varyFields(Headers responseHeaders)

        Returns the names of the request headers that need to be checked for equality when caching.

      • varyHeaders

         static Headers varyHeaders(MobonResponse mobonResponse)

        Returns the subset of the headers in {@code mobonResponse}'s request that impact the content ofmobonResponse's body.

      • varyHeaders

         static Headers varyHeaders(Headers requestHeaders, Headers responseHeaders)

        Returns the subset of the headers in {@code requestHeaders} that impact the content ofresponse's body.

      • parseChallenges

         static List<Challenge> parseChallenges(Headers responseHeaders, String challengeHeader)

        Parse RFC 7617 challenges, also wrong ordered ones.This API is only interested in the scheme name and realm.

      • hasBody

         static boolean hasBody(MobonResponse mobonResponse)

        Returns true if the mobonResponse must have a (possibly 0-length) body. See RFC 7231.

      • skipUntil

         static int skipUntil(String input, int pos, String characters)

        Returns the next index in {@code input} at or after {@code pos} that contains a character from {@code characters}. Returns the input length if none of the requested characters can be found.

      • skipWhitespace

         static int skipWhitespace(String input, int pos)

        Returns the next non-whitespace character in {@code input} that is white space. Result isundefined if input contains newline characters.

      • parseSeconds

         static int parseSeconds(String value, int defaultValue)

        Returns {@code value} as a positive integer, or 0 if it is negative, or {@code defaultValue} ifit cannot be parsed.