public final class ClientCookieEncoder extends CookieEncoder
Cookie#rawValue()
will be used.
Otherwise, Cookie.value()
will be used unquoted.
Note that multiple cookies are supposed to be sent at once in a single "Cookie" header.
// ExampleHttpRequest
req = ...; res.setHeader("Cookie",ClientCookieEncoder
.encode("JSESSIONID", "1234"));
ClientCookieDecoder
Modifier and Type | Field and Description |
---|---|
private static java.util.Comparator<Cookie> |
COOKIE_COMPARATOR
Sort cookies into decreasing order of path length, breaking ties by sorting into increasing chronological
order of creation time, as recommended by RFC 6265.
|
static ClientCookieEncoder |
LAX
Lax instance that doesn't validate name and value, and (for methods that accept multiple cookies) keeps
cookies in the order in which they were given.
|
static ClientCookieEncoder |
STRICT
Strict encoder that validates that name and value chars are in the valid scope and (for methods that accept
multiple cookies) sorts cookies into order of decreasing path length, as specified in RFC6265.
|
strict
Modifier | Constructor and Description |
---|---|
private |
ClientCookieEncoder(boolean strict) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
encode(java.util.Collection<? extends Cookie> cookies)
Encodes the specified cookies into a single Cookie header value.
|
java.lang.String |
encode(Cookie... cookies)
Encodes the specified cookies into a single Cookie header value.
|
java.lang.String |
encode(Cookie cookie)
Encodes the specified cookie into a Cookie header value.
|
java.lang.String |
encode(java.lang.Iterable<? extends Cookie> cookies)
Encodes the specified cookies into a single Cookie header value.
|
private void |
encode(java.lang.StringBuilder buf,
Cookie c) |
java.lang.String |
encode(java.lang.String name,
java.lang.String value)
Encodes the specified cookie into a Cookie header value.
|
validateCookie
public static final ClientCookieEncoder STRICT
public static final ClientCookieEncoder LAX
private static final java.util.Comparator<Cookie> COOKIE_COMPARATOR
public java.lang.String encode(java.lang.String name, java.lang.String value)
name
- the cookie namevalue
- the cookie valuepublic java.lang.String encode(Cookie cookie)
specified
- the cookiepublic java.lang.String encode(Cookie... cookies)
cookies
- some cookiespublic java.lang.String encode(java.util.Collection<? extends Cookie> cookies)
cookies
- some cookiespublic java.lang.String encode(java.lang.Iterable<? extends Cookie> cookies)
cookies
- some cookiesprivate void encode(java.lang.StringBuilder buf, Cookie c)