public class MockCookie
extends Cookie
Cookie
with extra directives, as defined in
RFC 6265.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
sameSite |
private static long |
serialVersionUID |
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 |
---|---|
private static java.lang.String |
extractDirectiveValue(java.lang.String directive) |
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.
|
private static final long serialVersionUID
@Nullable private java.lang.String sameSite
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" valueprivate static java.lang.String extractDirectiveValue(java.lang.String directive)