public interface Cookie extends Comparable<Cookie>
| Modifier and Type | Field and Description |
|---|---|
static long |
UNDEFINED_MAX_AGE
Constant for undefined MaxAge attribute value.
|
| Modifier and Type | Method and Description |
|---|---|
static CookieBuilder |
builder(String name,
String value)
Returns a newly created
CookieBuilder which builds a Cookie. |
default int |
compareTo(Cookie c) |
String |
domain()
Returns the domain of this
Cookie. |
static Cookies |
fromCookieHeader(boolean strict,
String cookieHeader)
Decodes the specified
"Cookie" header value into a set of Cookies. |
static Cookies |
fromCookieHeader(String cookieHeader)
Decodes the specified
"Cookie" header value into a set of Cookies. |
static Cookie |
fromSetCookieHeader(boolean strict,
String setCookieHeader)
Decodes the specified
"Set-Cookie" header value into a Cookie. |
static Cookie |
fromSetCookieHeader(String setCookieHeader)
Decodes the specified
"Set-Cookie" header value into a Cookie. |
static Cookies |
fromSetCookieHeaders(boolean strict,
Collection<String> setCookieHeaders)
Decodes the specified
"Set-Cookie" header values into Cookies. |
static Cookies |
fromSetCookieHeaders(boolean strict,
Iterable<String> setCookieHeaders)
Decodes the specified
"Set-Cookie" header values into Cookies. |
static Cookies |
fromSetCookieHeaders(boolean strict,
String... setCookieHeaders)
Decodes the specified
"Set-Cookie" header values into Cookies. |
static Cookies |
fromSetCookieHeaders(Collection<String> setCookieHeaders)
Decodes the specified
"Set-Cookie" header values into Cookies. |
static Cookies |
fromSetCookieHeaders(Iterable<String> setCookieHeaders)
Decodes the specified
"Set-Cookie" header values into Cookies. |
static Cookies |
fromSetCookieHeaders(String... setCookieHeaders)
Decodes the specified
"Set-Cookie" header values into Cookies. |
boolean |
isHttpOnly()
Returns whether this
Cookie can only be accessed via HTTP. |
boolean |
isSecure()
Returns whether this
Cookie is secure. |
boolean |
isValueQuoted()
Returns whether the raw value of this
Cookie was wrapped with double quotes
in the original "Set-Cookie" header. |
long |
maxAge()
Returns the maximum age of this
Cookie in seconds. |
String |
name()
Returns the name of this
Cookie. |
static Cookie |
of(String name,
String value)
Returns a newly created
Cookie. |
String |
path()
Returns the path of this
Cookie. |
String |
sameSite()
Returns the
"SameSite" attribute of this Cookie. |
default CookieBuilder |
toBuilder()
Returns a new
CookieBuilder created from this Cookie. |
default String |
toCookieHeader()
Encodes this
Cookie into a single "Cookie" header value. |
default String |
toCookieHeader(boolean strict)
Encodes this
Cookie into a single "Cookie" header value. |
static String |
toCookieHeader(boolean strict,
Collection<? extends Cookie> cookies)
Encodes the specified
Cookies into a "Cookie" header value. |
static String |
toCookieHeader(boolean strict,
Cookie... cookies)
Encodes the specified
Cookies into a "Cookie" header value. |
static String |
toCookieHeader(boolean strict,
Iterable<? extends Cookie> cookies)
Encodes the specified
Cookies into a "Cookie" header value. |
static String |
toCookieHeader(Collection<? extends Cookie> cookies)
Encodes the specified
Cookies into a "Cookie" header value. |
static String |
toCookieHeader(Cookie... cookies)
Encodes the specified
Cookies into a "Cookie" header value. |
static String |
toCookieHeader(Iterable<? extends Cookie> cookies)
Encodes the specified
Cookies into a "Cookie" header value. |
default String |
toSetCookieHeader()
Encodes this
Cookie into a single "Set-Cookie" header value. |
default String |
toSetCookieHeader(boolean strict)
Encodes this
Cookie into a single "Set-Cookie" header value. |
static List<String> |
toSetCookieHeaders(boolean strict,
Collection<? extends Cookie> cookies)
Encodes the specified
Cookies into "Set-Cookie" header values. |
static List<String> |
toSetCookieHeaders(boolean strict,
Cookie... cookies)
Encodes the specified
Cookies into "Set-Cookie" header values. |
static List<String> |
toSetCookieHeaders(boolean strict,
Iterable<? extends Cookie> cookies)
Encodes the specified
Cookies into "Set-Cookie" header values. |
static List<String> |
toSetCookieHeaders(Collection<? extends Cookie> cookies)
Encodes the specified
Cookies into "Set-Cookie" header values. |
static List<String> |
toSetCookieHeaders(Cookie... cookies)
Encodes the specified
Cookies into "Set-Cookie" header values. |
static List<String> |
toSetCookieHeaders(Iterable<? extends Cookie> cookies)
Encodes the specified
Cookies into "Set-Cookie" header values. |
String |
value()
Returns the value of this
Cookie. |
default Cookie |
withMutations(Consumer<CookieBuilder> mutator)
|
static final long UNDEFINED_MAX_AGE
static CookieBuilder builder(String name, String value)
CookieBuilder which builds a Cookie.static Cookies fromCookieHeader(String cookieHeader)
"Cookie" header value into a set of Cookies.cookieHeader - the "Cookie" header value.Cookies.static Cookies fromCookieHeader(boolean strict, String cookieHeader)
"Cookie" header value into a set of Cookies.strict - whether to validate that the cookie names and values are in the valid scope
defined in RFC 6265.cookieHeader - the "Cookie" header value.Cookies.static String toCookieHeader(Cookie... cookies)
Cookies into a "Cookie" header value.cookies - the Cookies to encode."Cookie" header value.static String toCookieHeader(Iterable<? extends Cookie> cookies)
Cookies into a "Cookie" header value.cookies - the Cookies to encode."Cookie" header value.IllegalArgumentException - if cookies is empty.static String toCookieHeader(Collection<? extends Cookie> cookies)
Cookies into a "Cookie" header value.cookies - the Cookies to encode."Cookie" header value.IllegalArgumentException - if cookies is empty.static String toCookieHeader(boolean strict, Cookie... cookies)
Cookies into a "Cookie" header value.strict - whether to validate that cookie names and values are in the valid scope
defined in RFC 6265 and to sort the Cookies into order of decreasing path length,
as specified in RFC 6265. If false, the Cookies are encoded in the order
in which they are given.cookies - the Cookies to encode."Cookie" header value.static String toCookieHeader(boolean strict, Iterable<? extends Cookie> cookies)
Cookies into a "Cookie" header value.strict - whether to validate that cookie names and values are in the valid scope
defined in RFC 6265 and to sort the Cookies into order of decreasing path length,
as specified in RFC 6265. If false, the Cookies are encoded in the order
in which they are given.cookies - the Cookies to encode."Cookie" header value.IllegalArgumentException - if cookies is empty.static String toCookieHeader(boolean strict, Collection<? extends Cookie> cookies)
Cookies into a "Cookie" header value.strict - whether to validate that cookie names and values are in the valid scope
defined in RFC 6265 and to sort the Cookies into order of decreasing path length,
as specified in RFC 6265. If false, the Cookies are encoded in the order
in which they are given.cookies - the Cookies to encode."Cookie" header value.IllegalArgumentException - if cookies is empty.static Cookie fromSetCookieHeader(String setCookieHeader)
"Set-Cookie" header value into a Cookie.setCookieHeader - the "Set-Cookie" header value.Cookie if decoded successfully, or null otherwise.static Cookie fromSetCookieHeader(boolean strict, String setCookieHeader)
"Set-Cookie" header value into a Cookie.strict - whether to validate the cookie names and values are in the valid scope defined in RFC 6265.setCookieHeader - the "Set-Cookie" header value.Cookie if decoded successfully, or null otherwise.static Cookies fromSetCookieHeaders(String... setCookieHeaders)
"Set-Cookie" header values into Cookies.setCookieHeaders - the "Set-Cookie" header values.Cookies.static Cookies fromSetCookieHeaders(Iterable<String> setCookieHeaders)
"Set-Cookie" header values into Cookies.setCookieHeaders - the "Set-Cookie" header values.Cookies.static Cookies fromSetCookieHeaders(Collection<String> setCookieHeaders)
"Set-Cookie" header values into Cookies.setCookieHeaders - the "Set-Cookie" header values.Cookies.static Cookies fromSetCookieHeaders(boolean strict, String... setCookieHeaders)
"Set-Cookie" header values into Cookies.strict - whether to validate the cookie names and values are in the valid scope defined in RFC 6265.setCookieHeaders - the "Set-Cookie" header values.Cookies.static Cookies fromSetCookieHeaders(boolean strict, Iterable<String> setCookieHeaders)
"Set-Cookie" header values into Cookies.strict - whether to validate the cookie names and values are in the valid scope defined in RFC 6265.setCookieHeaders - the "Set-Cookie" header values.Cookies.static Cookies fromSetCookieHeaders(boolean strict, Collection<String> setCookieHeaders)
"Set-Cookie" header values into Cookies.strict - whether to validate the cookie names and values are in the valid scope defined in RFC 6265.setCookieHeaders - the "Set-Cookie" header values.Cookies.static List<String> toSetCookieHeaders(Cookie... cookies)
Cookies into "Set-Cookie" header values.cookies - the Cookies to encode."Set-Cookie" header values.static List<String> toSetCookieHeaders(Iterable<? extends Cookie> cookies)
Cookies into "Set-Cookie" header values.cookies - the Cookies to encode."Set-Cookie" header values.static List<String> toSetCookieHeaders(Collection<? extends Cookie> cookies)
Cookies into "Set-Cookie" header values.cookies - the Cookies to encode."Set-Cookie" header values.static List<String> toSetCookieHeaders(boolean strict, Cookie... cookies)
Cookies into "Set-Cookie" header values.strict - whether to validate that the cookie names and values are in the valid scope
defined in RFC 6265.cookies - the Cookies to encode."Set-Cookie" header values.static List<String> toSetCookieHeaders(boolean strict, Iterable<? extends Cookie> cookies)
Cookies into "Set-Cookie" header values.strict - whether to validate that the cookie names and values are in the valid scope
defined in RFC 6265.cookies - the Cookies to encode."Set-Cookie" header values.static List<String> toSetCookieHeaders(boolean strict, Collection<? extends Cookie> cookies)
Cookies into "Set-Cookie" header values.strict - whether to validate that the cookie names and values are in the valid scope
defined in RFC 6265.cookies - the Cookies to encode."Set-Cookie" header values.boolean isValueQuoted()
Cookie was wrapped with double quotes
in the original "Set-Cookie" header.long maxAge()
Cookie in seconds.UNDEFINED_MAX_AGE if unspecified.boolean isSecure()
Cookie is secure.boolean isHttpOnly()
String sameSite()
"SameSite" attribute of this Cookie."SameSite" attribute, or null.default String toCookieHeader()
Cookie into a single "Cookie" header value.
Note that you must use toCookieHeader(Collection) when encoding more than one Cookie,
because it is prohibited to send multiple "Cookie" headers in an HTTP request,
according to RFC 6265."Cookie" header value.default String toCookieHeader(boolean strict)
Cookie into a single "Cookie" header value.
Note that you must use toCookieHeader(boolean, Collection) when encoding
more than one Cookie, because it is prohibited to send multiple "Cookie" headers
in an HTTP request, according to RFC 6265.strict - whether to validate that the cookie name and value are in the valid scope
defined in RFC 6265."Cookie" header value.default String toSetCookieHeader()
Cookie into a single "Set-Cookie" header value."Set-Cookie" header value.default String toSetCookieHeader(boolean strict)
Cookie into a single "Set-Cookie" header value.strict - whether to validate that the cookie name and value are in the valid scope
defined in RFC 6265."Set-Cookie" header value.default CookieBuilder toBuilder()
CookieBuilder created from this Cookie.withMutations(Consumer)default Cookie withMutations(Consumer<CookieBuilder> mutator)
Cookie which is the result from the mutation by the specified Consumer.
This method is a shortcut for:
builder = toBuilder();
mutator.accept(builder);
return builder.build();
toBuilder()default int compareTo(Cookie c)
compareTo in interface Comparable<Cookie>Copyright © 2020 LeanCloud. All rights reserved.