类 Cookie

java.lang.Object
com.lark.oapi.okhttp.Cookie

public final class Cookie extends Object
An RFC 6265 Cookie.

This class doesn't support additional attributes on cookies, like Chromium's Priority=HIGH extension.

  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static final class 
    Builds a cookie.
  • 方法概要

    修饰符和类型
    方法
    说明
    Returns the cookie's domain.
    boolean
    equals(Object other)
     
    long
    Returns the time that this cookie expires, in the same format as System.currentTimeMillis().
    int
     
    boolean
    Returns true if this cookie's domain should be interpreted as a single host name, or false if it should be interpreted as a pattern.
    boolean
    Returns true if this cookie should be limited to only HTTP APIs.
    boolean
    Returns true if this cookie should be included on a request to url.
    Returns a non-empty string with this cookie's name.
    static Cookie
    parse(HttpUrl url, String setCookie)
    Attempt to parse a Set-Cookie HTTP header value setCookie as a cookie.
    static List<Cookie>
    parseAll(HttpUrl url, Headers headers)
    Returns all of the cookies from a set of HTTP response headers.
    Returns this cookie's path.
    boolean
    Returns true if this cookie does not expire at the end of the current session.
    boolean
    Returns true if this cookie should be limited to only HTTPS requests.
     
    Returns a possibly-empty string with this cookie's value.

    从类继承的方法 java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • 方法详细资料

    • parse

      @Nullable public static Cookie parse(HttpUrl url, String setCookie)
      Attempt to parse a Set-Cookie HTTP header value setCookie as a cookie. Returns null if setCookie is not a well-formed cookie.
    • parseAll

      public static List<Cookie> parseAll(HttpUrl url, Headers headers)
      Returns all of the cookies from a set of HTTP response headers.
    • name

      public String name()
      Returns a non-empty string with this cookie's name.
    • value

      public String value()
      Returns a possibly-empty string with this cookie's value.
    • persistent

      public boolean persistent()
      Returns true if this cookie does not expire at the end of the current session.
    • expiresAt

      public long expiresAt()
      Returns the time that this cookie expires, in the same format as System.currentTimeMillis(). This is December 31, 9999 if the cookie is not persistent, in which case it will expire at the end of the current session.

      This may return a value less than the current time, in which case the cookie is already expired. Webservers may return expired cookies as a mechanism to delete previously set cookies that may or may not themselves be expired.

    • hostOnly

      public boolean hostOnly()
      Returns true if this cookie's domain should be interpreted as a single host name, or false if it should be interpreted as a pattern. This flag will be false if its Set-Cookie header included a domain attribute.

      For example, suppose the cookie's domain is example.com. If this flag is true it matches only example.com. If this flag is false it matches example.com and all subdomains including api.example.com, www.example.com, and beta.api.example.com.

    • domain

      public String domain()
      Returns the cookie's domain. If hostOnly() returns true this is the only domain that matches this cookie; otherwise it matches this domain and all subdomains.
    • path

      public String path()
      Returns this cookie's path. This cookie matches URLs prefixed with path segments that match this path's segments. For example, if this path is /foo this cookie matches requests to /foo and /foo/bar, but not / or /football.
    • httpOnly

      public boolean httpOnly()
      Returns true if this cookie should be limited to only HTTP APIs. In web browsers this prevents the cookie from being accessible to scripts.
    • secure

      public boolean secure()
      Returns true if this cookie should be limited to only HTTPS requests.
    • matches

      public boolean matches(HttpUrl url)
      Returns true if this cookie should be included on a request to url. In addition to this check callers should also confirm that this cookie has not expired.
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • equals

      public boolean equals(@Nullable Object other)
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object