类 MockCookie

java.lang.Object
jakarta.servlet.http.Cookie
cn.taketoday.mock.web.MockCookie
所有已实现的接口:
Serializable, Cloneable

public class MockCookie extends jakarta.servlet.http.Cookie
Extension of Cookie with extra attributes, as defined in RFC 6265.
从以下版本开始:
4.0
作者:
Vedran Pavic, Juergen Hoeller, Sam Brannen
另请参阅:
  • 字段详细资料

  • 构造器详细资料

    • MockCookie

      public MockCookie(String name, String value)
      Construct a new MockCookie with the supplied name and value.
      参数:
      name - the name
      value - the value
      另请参阅:
      • Cookie(String, String)
  • 方法详细资料

    • setExpires

      public void setExpires(@Nullable ZonedDateTime expires)
      Set the "Expires" attribute for this cookie.
    • getExpires

      @Nullable public ZonedDateTime getExpires()
      Get the "Expires" attribute for this cookie.
      返回:
      the "Expires" attribute for this cookie, or null if not set
    • setSameSite

      public void setSameSite(@Nullable String sameSite)
      Set the "SameSite" attribute for this cookie.

      This limits the scope of the cookie such that it will only be attached to same-site requests if the supplied value is "Strict" or cross-site requests if the supplied value is "Lax".

      另请参阅:
    • getSameSite

      @Nullable public String getSameSite()
      Get the "SameSite" attribute for this cookie.
      返回:
      the "SameSite" attribute for this cookie, or null if not set
    • parse

      public static MockCookie parse(String setCookieHeader)
      Factory method that parses the value of the supplied "Set-Cookie" header.
      参数:
      setCookieHeader - the "Set-Cookie" value; never null or empty
      返回:
      the created cookie
    • extractAttributeValue

      private static String extractAttributeValue(String attribute, String header)
    • setAttribute

      public void setAttribute(String name, @Nullable String value)
      覆盖:
      setAttribute 在类中 jakarta.servlet.http.Cookie
    • toString

      public String toString()
      覆盖:
      toString 在类中 jakarta.servlet.http.Cookie