org.apache.tomcat.util.http

Class Cookies

public final class Cookies extends Object

A collection of cookies - reusable and tuned for server side performance. Based on RFC2965 ( and 2109 ) This class is not synchronized.

Author: Costin Manolache kevin seguin

Field Summary
static booleanALLOW_EQUALS_IN_VALUE
If true, cookie values are allowed to contain an equals character without being quoted.
static intINITIAL_SIZE
protected static boolean[]separators
static char[]SEPARATORS
Constructor Summary
Cookies(MimeHeaders headers)
Construct a new cookie collection, that will extract the information from headers.
Cookies()
Construct a new uninitialized cookie collection.
Method Summary
ServerCookieaddCookie()
Register a new, unitialized cookie.
static booleanequals(String s, byte[] b, int start, int end)
ServerCookiegetCookie(int idx)
intgetCookieCount()
static intgetQuotedValueEndPosition(byte[] bytes, int off, int end)
Given a starting position after an initial quote chracter, this gets the position of the end quote.
static intgetTokenEndPosition(byte[] bytes, int off, int end)
static booleanisSeparator(byte c)
Returns true if the byte is a separator character as defined in RFC2619.
static booleanisWhiteSpace(byte c)
Returns true if the byte is a whitespace character as defined in RFC2619 JVK
voidlog(String s)
voidprocessCookieHeader(byte[] bytes, int off, int len)
Parses a cookie header after the initial "Cookie:" [WS][$]token[WS]=[WS](token|QV)[;|,] RFC 2965 JVK
voidprocessCookies(MimeHeaders headers)
Add all Cookie found in the headers of a request.
voidrecycle()
Recycle.
voidsetHeaders(MimeHeaders headers)
Set the headers from which cookies will be pulled.
StringtoString()
EXPENSIVE!

Field Detail

ALLOW_EQUALS_IN_VALUE

public static final boolean ALLOW_EQUALS_IN_VALUE
If true, cookie values are allowed to contain an equals character without being quoted.

INITIAL_SIZE

public static final int INITIAL_SIZE

separators

protected static final boolean[] separators

SEPARATORS

public static final char[] SEPARATORS

Constructor Detail

Cookies

public Cookies(MimeHeaders headers)
Construct a new cookie collection, that will extract the information from headers.

Parameters: headers Cookies are lazy-evaluated and will extract the information from the provided headers.

Cookies

public Cookies()
Construct a new uninitialized cookie collection. Use Cookies to initialize.

Method Detail

addCookie

public ServerCookie addCookie()
Register a new, unitialized cookie. Cookies are recycled, and most of the time an existing ServerCookie object is returned. The caller can set the name/value and attributes for the cookie

equals

public static boolean equals(String s, byte[] b, int start, int end)

getCookie

public ServerCookie getCookie(int idx)

getCookieCount

public int getCookieCount()

getQuotedValueEndPosition

public static final int getQuotedValueEndPosition(byte[] bytes, int off, int end)
Given a starting position after an initial quote chracter, this gets the position of the end quote. This escapes anything after a '\' char JVK RFC 2616

getTokenEndPosition

public static final int getTokenEndPosition(byte[] bytes, int off, int end)

Deprecated: - Use private method (byte[], int, int, boolean) instead

isSeparator

public static final boolean isSeparator(byte c)
Returns true if the byte is a separator character as defined in RFC2619. Since this is called often, this function should be organized with the most probable outcomes first. JVK

isWhiteSpace

public static final boolean isWhiteSpace(byte c)
Returns true if the byte is a whitespace character as defined in RFC2619 JVK

log

public void log(String s)

processCookieHeader

public final void processCookieHeader(byte[] bytes, int off, int len)
Parses a cookie header after the initial "Cookie:" [WS][$]token[WS]=[WS](token|QV)[;|,] RFC 2965 JVK

processCookies

public void processCookies(MimeHeaders headers)
Add all Cookie found in the headers of a request.

recycle

public void recycle()
Recycle.

setHeaders

public void setHeaders(MimeHeaders headers)
Set the headers from which cookies will be pulled. This has the side effect of recycling the object.

Parameters: headers Cookies are lazy-evaluated and will extract the information from the provided headers.

toString

public String toString()
EXPENSIVE!!! only for debugging.
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.