public class MockCookie extends Cookie
Cookie
with extra attributes, as defined in
RFC 6265.Constructor and Description |
---|
MockCookie(String name,
String value)
Construct a new
MockCookie with the supplied name and value. |
Modifier and Type | Method and Description |
---|---|
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.
|
clone, getComment, getDomain, getMaxAge, getName, getPath, getSecure, getValue, getVersion, isHttpOnly, setComment, setDomain, setHttpOnly, setMaxAge, setPath, setSecure, setValue, setVersion
public MockCookie(String name, String value)
MockCookie
with the supplied name and value.name
- the namevalue
- the valueCookie.Cookie(String, String)
public void setExpires(@Nullable ZonedDateTime expires)
@Nullable public ZonedDateTime getExpires()
null
if not setpublic void setSameSite(@Nullable String sameSite)
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"
.
@Nullable public String getSameSite()
null
if not setpublic static MockCookie parse(String setCookieHeader)
setCookieHeader
- the "Set-Cookie" value; never null
or empty