Top Description Fields Constructors Methods
io.netty.handler.codec.http.cookie

public final Class ClientCookieEncoder

extends CookieEncoder
Class Inheritance
Static Imports
io.netty.handler.codec.http.cookie.CookieUtil.add, .CookieUtil.addQuoted, .CookieUtil.stringBuilder, .CookieUtil.stripTrailingSeparator, .CookieUtil.stripTrailingSeparatorOrNull, io.netty.util.internal.ObjectUtil.checkNotNull

A RFC6265 compliant cookie encoder to be used client side, so only name=value pairs are sent. Note that multiple cookies are supposed to be sent at once in a single "Cookie" header.
// Example
HttpRequest req = ...;
res.setHeader("Cookie", ClientCookieEncoder.encode("JSESSIONID", "1234"));
See Also
ClientCookieDecoder

Field Summary

Modifier and TypeField and Description
public static final 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.

public static final 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.

Inherited from io.netty.handler.codec.http.cookie.CookieEncoder:
strict

Constructor Summary

AccessConstructor and Description
private
ClientCookieEncoder(boolean strict)

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

a Rfc6265 style Cookie header value
encode
(String
the cookie name
name
,
String
the cookie value
value
)

Encodes the specified cookie into a Cookie header value.

public String

Returns:

a Rfc6265 style Cookie header value
encode
(Cookie
the specified cookie
cookie
)

Encodes the specified cookie into a Cookie header value.

public String

Returns:

a Rfc6265 style Cookie header value, null if no cookies are passed.
encode
(Cookie...
some cookies
cookies
)

Encodes the specified cookies into a single Cookie header value.

public String

Returns:

a Rfc6265 style Cookie header value, null if no cookies are passed.
encode
(Collection<? extends Cookie>
some cookies
cookies
)

Encodes the specified cookies into a single Cookie header value.

public String

Returns:

a Rfc6265 style Cookie header value, null if no cookies are passed.
encode
(Iterable<? extends Cookie>
some cookies
cookies
)

Encodes the specified cookies into a single Cookie header value.

private void
Inherited from io.netty.handler.codec.http.cookie.CookieEncoder:
validateCookie

Field Detail

LAXback to summary
public static final 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.

STRICTback to summary
public static final 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.

Constructor Detail

ClientCookieEncoderback to summary
private ClientCookieEncoder(boolean strict)

Method Detail

encodeback to summary
public String encode(String name, String value)

Encodes the specified cookie into a Cookie header value.

Parameters
name:String

the cookie name

value:String

the cookie value

Returns:String

a Rfc6265 style Cookie header value

encodeback to summary
public String encode(Cookie cookie)

Encodes the specified cookie into a Cookie header value.

Parameters
cookie:Cookie

the specified cookie

Returns:String

a Rfc6265 style Cookie header value

encodeback to summary
public String encode(Cookie... cookies)

Encodes the specified cookies into a single Cookie header value.

Parameters
cookies:Cookie[]

some cookies

Returns:String

a Rfc6265 style Cookie header value, null if no cookies are passed.

encodeback to summary
public String encode(Collection<? extends Cookie> cookies)

Encodes the specified cookies into a single Cookie header value.

Parameters
cookies:Collection<? extends Cookie>

some cookies

Returns:String

a Rfc6265 style Cookie header value, null if no cookies are passed.

encodeback to summary
public String encode(Iterable<? extends Cookie> cookies)

Encodes the specified cookies into a single Cookie header value.

Parameters
cookies:Iterable<? extends Cookie>

some cookies

Returns:String

a Rfc6265 style Cookie header value, null if no cookies are passed.

encodeback to summary
private void encode(StringBuilder buf, Cookie c)