org.apache.tomcat.util.http

Class ServerCookie

public class ServerCookie extends Object implements Serializable

Server-side cookie representation. Allows recycling and uses MessageBytes as low-level representation ( and thus the byte-> char conversion can be delayed until we know the charset ). Tomcat.core uses this recyclable object to represent cookies, and the facade will convert it to the external representation.
Field Summary
static booleanALWAYS_ADD_EXPIRES
If set to false, we don't use the IE6/7 Max-Age/Expires work around
static booleanSTRICT_SERVLET_COMPLIANCE
If set to true, we parse cookies according to the servlet spec,
Constructor Summary
ServerCookie()
Method Summary
static booleanalreadyQuoted(String value)
static voidappendCookieValue(StringBuffer headerBuf, int version, String name, String value, String path, String domain, String comment, int maxAge, boolean isSecure, boolean isHttpOnly)
static booleancheckName(String name)
static booleancontainsCTL(String value, int version)
MessageBytesgetComment()
StringgetCookieHeaderName()
Return the header name to set the cookie, based on cookie version.
static StringgetCookieHeaderName(int version)
Return the header name to set the cookie, based on cookie version.
MessageBytesgetDomain()
intgetMaxAge()
MessageBytesgetName()
MessageBytesgetPath()
booleangetSecure()
MessageBytesgetValue()
intgetVersion()
static booleanisToken(String value)
static booleanisToken(String value, String literals)
static booleanisToken2(String value)
static booleanisToken2(String value, String literals)
static intmaybeQuote2(int version, StringBuffer buf, String value)
Quotes values using rules that vary depending on Cookie version.
static intmaybeQuote2(int version, StringBuffer buf, String value, boolean allowVersionSwitch)
static intmaybeQuote2(int version, StringBuffer buf, String value, String literals, boolean allowVersionSwitch)
voidrecycle()
voidsetMaxAge(int expiry)
voidsetSecure(boolean flag)
voidsetVersion(int v)
StringtoString()
static voidunescapeDoubleQuotes(ByteChunk bc)
Unescapes any double quotes in the given cookie value.

Field Detail

ALWAYS_ADD_EXPIRES

public static final boolean ALWAYS_ADD_EXPIRES
If set to false, we don't use the IE6/7 Max-Age/Expires work around

STRICT_SERVLET_COMPLIANCE

public static final boolean STRICT_SERVLET_COMPLIANCE
If set to true, we parse cookies according to the servlet spec,

Constructor Detail

ServerCookie

public ServerCookie()

Method Detail

alreadyQuoted

public static boolean alreadyQuoted(String value)

appendCookieValue

public static void appendCookieValue(StringBuffer headerBuf, int version, String name, String value, String path, String domain, String comment, int maxAge, boolean isSecure, boolean isHttpOnly)

checkName

public static boolean checkName(String name)

Deprecated: - Not used

containsCTL

public static boolean containsCTL(String value, int version)

getComment

public MessageBytes getComment()

getCookieHeaderName

public String getCookieHeaderName()
Return the header name to set the cookie, based on cookie version.

getCookieHeaderName

public static String getCookieHeaderName(int version)
Return the header name to set the cookie, based on cookie version.

getDomain

public MessageBytes getDomain()

getMaxAge

public int getMaxAge()

getName

public MessageBytes getName()

getPath

public MessageBytes getPath()

getSecure

public boolean getSecure()

getValue

public MessageBytes getValue()

getVersion

public int getVersion()

isToken

public static boolean isToken(String value)

isToken

public static boolean isToken(String value, String literals)

isToken2

public static boolean isToken2(String value)

isToken2

public static boolean isToken2(String value, String literals)

maybeQuote2

public static int maybeQuote2(int version, StringBuffer buf, String value)
Quotes values using rules that vary depending on Cookie version.

Parameters: version buf value

maybeQuote2

public static int maybeQuote2(int version, StringBuffer buf, String value, boolean allowVersionSwitch)

maybeQuote2

public static int maybeQuote2(int version, StringBuffer buf, String value, String literals, boolean allowVersionSwitch)

recycle

public void recycle()

setMaxAge

public void setMaxAge(int expiry)

setSecure

public void setSecure(boolean flag)

setVersion

public void setVersion(int v)

toString

public String toString()

unescapeDoubleQuotes

public static void unescapeDoubleQuotes(ByteChunk bc)
Unescapes any double quotes in the given cookie value.

Parameters: bc The cookie value to modify

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.