Top Description Inners Fields Constructors Methods
org.apache.tomcat.util.http.parser

public Class Cookie

extends Object
Class Inheritance
Imports
java.nio.charset.StandardCharsets, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.http.ServerCookie, .ServerCookies, org.apache.tomcat.util.log.UserDataHelper, org.apache.tomcat.util.res.StringManager

Cookie header parser based on RFC6265

The parsing of cookies using RFC6265 is more relaxed that the specification in the following ways:

Implementation note:
This class has been carefully tuned. Before committing any changes, ensure that the TesterCookiePerformance unit test continues to give results within 1% for the old and new parsers.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Cookie.ByteBuffer

Custom implementation that skips many of the safety checks in java.nio.ByteBuffer.

Field Summary

Modifier and TypeField and Description
private static final byte
private static final byte
private static final byte[]
private static final byte
private static final UserDataHelper
private static final boolean[]
private static final boolean[]
private static final Log
private static final byte
private static final byte
private static final byte
private static final StringManager
private static final byte
private static final byte

Constructor Summary

AccessConstructor and Description

Method Summary

Modifier and TypeMethod and Description
private static void
public static void
parseCookie(byte[] bytes, int offset, int len, ServerCookies serverCookies)

private static Cookie.ByteBuffer
readCookieValueRfc6265(Cookie.ByteBuffer bb)

Similar to readCookieValue() but treats a comma as part of an invalid value.

private static Cookie.ByteBuffer
private static SkipResult
skipByte(Cookie.ByteBuffer bb, byte target)

private static void
private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMMA_BYTEback to summary
private static final byte COMMA_BYTE
DEL_BYTEback to summary
private static final byte DEL_BYTE
EMPTY_BYTESback to summary
private static final byte[] EMPTY_BYTES
EQUALS_BYTEback to summary
private static final byte EQUALS_BYTE
invalidCookieLogback to summary
private static final UserDataHelper invalidCookieLog
isCookieOctetback to summary
private static final boolean[] isCookieOctet
isTextback to summary
private static final boolean[] isText
logback to summary
private static final Log log
QUOTE_BYTEback to summary
private static final byte QUOTE_BYTE
SEMICOLON_BYTEback to summary
private static final byte SEMICOLON_BYTE
SLASH_BYTEback to summary
private static final byte SLASH_BYTE
smback to summary
private static final StringManager sm
SPACE_BYTEback to summary
private static final byte SPACE_BYTE
TAB_BYTEback to summary
private static final byte TAB_BYTE

Constructor Detail

Method Detail

logInvalidHeaderback to summary
private static void logInvalidHeader(int start, Cookie.ByteBuffer bb)
parseCookieback to summary
public static void parseCookie(byte[] bytes, int offset, int len, ServerCookies serverCookies)
readCookieValueRfc6265back to summary
private static Cookie.ByteBuffer readCookieValueRfc6265(Cookie.ByteBuffer bb)

Similar to readCookieValue() but treats a comma as part of an invalid value.

readTokenback to summary
private static Cookie.ByteBuffer readToken(Cookie.ByteBuffer bb)
skipByteback to summary
private static SkipResult skipByte(Cookie.ByteBuffer bb, byte target)
skipLWSback to summary
private static void skipLWS(Cookie.ByteBuffer bb)
skipUntilSemiColonback to summary
private static void skipUntilSemiColon(Cookie.ByteBuffer bb)
org.apache.tomcat.util.http.parser back to summary

private Class Cookie.ByteBuffer

extends Object
Class Inheritance

Custom implementation that skips many of the safety checks in java.nio.ByteBuffer.

Field Summary

Modifier and TypeField and Description
private final byte[]
private int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
ByteBuffer(byte[] bytes, int offset, int len)

Method Summary

Modifier and TypeMethod and Description
public byte[]
public byte
get()

public boolean
public int
public int
public void
position(int position)

public int
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bytesback to summary
private final byte[] bytes
limitback to summary
private int limit
positionback to summary
private int position

Constructor Detail

ByteBufferback to summary
pack-priv ByteBuffer(byte[] bytes, int offset, int len)

Method Detail

arrayback to summary
public byte[] array()
getback to summary
public byte get()
hasRemainingback to summary
public boolean hasRemaining()
limitback to summary
public int limit()
positionback to summary
public int position()
positionback to summary
public void position(int position)
remainingback to summary
public int remaining()
rewindback to summary
public void rewind()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override