public final class CookieEncoder extends Object
Cookies 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 Cookies added by the #addCookie(String, String)
method. Once #encode() is called, all added Cookies are
encoded into an HTTP header value and all Cookies in the internal
data structure are removed so that the encoder can start over.
// Client-side exampleHttpRequestreq = ...;CookieEncoderencoder = newCookieEncoder(false); encoder.addCookie("JSESSIONID", "1234"); res.setHeader("Cookie", encoder.encode()); // Server-side exampleHttpResponseres = ...;CookieEncoderencoder = newCookieEncoder(true); encoder.addCookie("JSESSIONID", "1234"); res.setHeader("Set-Cookie", encoder.encode());
CookieDecoderpublic static String encodeClientSide(Collection<Cookie> cookies, boolean useRFC6265Style)
Copyright © 2013. All Rights Reserved.