public class MockCookie extends Cookie
Cookie
with extra attributes, as defined in
RFC 6265.Constructor and Description |
---|
MockCookie(java.lang.String name,
java.lang.String value)
Constructor with the cookie name and value.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getSameSite()
Return the "SameSite" attribute, or
null if not set. |
static MockCookie |
parse(java.lang.String setCookieHeader)
Factory method that parses the value of a "Set-Cookie" header.
|
void |
setSameSite(java.lang.String sameSite)
Add the "SameSite" attribute to the cookie.
|
clone, getComment, getDomain, getMaxAge, getName, getPath, getSecure, getValue, getVersion, isHttpOnly, setComment, setDomain, setHttpOnly, setMaxAge, setPath, setSecure, setValue, setVersion
public MockCookie(java.lang.String name, java.lang.String value)
name
- the namevalue
- the valueCookie.Cookie(String, String)
public void setSameSite(@Nullable java.lang.String sameSite)
This limits the scope of the cookie such that it will only be attached
to same site requests if "Strict"
or cross-site requests if
"Lax"
.
@Nullable public java.lang.String getSameSite()
null
if not set.public static MockCookie parse(java.lang.String setCookieHeader)
setCookieHeader
- the "Set-Cookie" value; never null
or empty