public final class CookieEncoder extends Object
Cookie
s into an HTTP header value. This encoder can encode
the HTTP cookie version 0, 1, and 2.
This encoder is stateful. It maintains an internal data structure that
holds the Cookie
s added by the #addCookie(String, String)
method. Once #encode()
is called, all added Cookie
s are
encoded into an HTTP header value and all Cookie
s in the internal
data structure are removed so that the encoder can start over.
// Client-side exampleHttpRequest
req = ...;CookieEncoder
encoder = newCookieEncoder
(false); encoder.addCookie("JSESSIONID", "1234"); res.setHeader("Cookie", encoder.encode()); // Server-side exampleHttpResponse
res = ...;CookieEncoder
encoder = newCookieEncoder
(true); encoder.addCookie("JSESSIONID", "1234"); res.setHeader("Set-Cookie", encoder.encode());
CookieDecoder
public static String encodeClientSide(Collection<Cookie> cookies, boolean useRFC6265Style)
Copyright © 2013. All rights reserved.