类 MockCookie
- java.lang.Object
- javax.servlet.http.Cookie
- org.springframework.mock.web.MockCookie
- 所有已实现的接口:
Serializable
,Cloneable
public class MockCookie extends Cookie
Extension ofCookie
with extra attributes, as defined in RFC 6265.- 从以下版本开始:
- 5.1
- 作者:
- Vedran Pavic, Juergen Hoeller, Sam Brannen
- 另请参阅:
- 序列化表格
构造器概要
构造器 构造器 说明 MockCookie(String name, String value)
Construct a newMockCookie
with the supplied name and value.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 ZonedDateTime
getExpires()
Get the "Expires" attribute for this cookie.String
getSameSite()
Get the "SameSite" attribute for this cookie.static MockCookie
parse(String setCookieHeader)
Factory method that parses the value of the supplied "Set-Cookie" header.void
setExpires(ZonedDateTime expires)
Set the "Expires" attribute for this cookie.void
setSameSite(String sameSite)
Set the "SameSite" attribute for this cookie.从类继承的方法 javax.servlet.http.Cookie
clone, getComment, getDomain, getMaxAge, getName, getPath, getSecure, getValue, getVersion, isHttpOnly, setComment, setDomain, setHttpOnly, setMaxAge, setPath, setSecure, setValue, setVersion
构造器详细资料
MockCookie
public MockCookie(String name, String value)
Construct a newMockCookie
with the supplied name and value.- 参数:
name
- the namevalue
- the value- 另请参阅:
Cookie(String, String)
方法详细资料
setExpires
public void setExpires(@Nullable ZonedDateTime expires)
Set the "Expires" attribute for this cookie.- 从以下版本开始:
- 5.1.11
getExpires
@Nullable public ZonedDateTime getExpires()
Get the "Expires" attribute for this cookie.- 返回:
- the "Expires" attribute for this cookie, or
null
if not set - 从以下版本开始:
- 5.1.11
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"
.- 另请参阅:
- RFC6265 bis
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; nevernull
or empty- 返回:
- the created cookie