Package org.eclipse.jetty.server
Class CookieCache
- All Implemented Interfaces:
Iterable<HttpCookie>
,Collection<HttpCookie>
,List<HttpCookie>
,ComplianceViolation.Listener
,CookieParser.Handler
public class CookieCache
extends AbstractList<HttpCookie>
implements CookieParser.Handler, ComplianceViolation.Listener
Cookie parser
Optimized stateful cookie parser. If the added fields are identical to those last added (as strings), then the cookies are not re-parsed.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
Fields inherited from class java.util.AbstractList
modCount
Fields inherited from interface org.eclipse.jetty.http.ComplianceViolation.Listener
NOOP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCookie
(String cookieName, String cookieValue, int cookieVersion, String cookieDomain, String cookiePath, String cookieComment) get
(int index) <C> C[]
getApiCookies
(Class<C> apiClass, Function<HttpCookie, C> convertor) static <C> C[]
getApiCookies
(Request request, Class<C> cookieClass, Function<HttpCookie, C> convertor) Get the API specific cookies for a request.static List<HttpCookie>
getCookies
(Request request) Get the core HttpCookies for a request.void
The compliance violation event.void
parseCookies
(HttpFields headers, ComplianceViolation.Listener complianceViolationListener) int
size()
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface org.eclipse.jetty.http.ComplianceViolation.Listener
initialize, onComplianceViolation, onRequestBegin, onRequestEnd
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
_rawFields
-
-
Constructor Details
-
CookieCache
public CookieCache() -
CookieCache
-
-
Method Details
-
getCookies
Get the core HttpCookies for a request. Cookies may be cached as arequest attribute
, failing that they may be cached in theComponent cache
, in which case they will be checked to see if they have changed since a previous request. Otherwise, they are parsed from the request headers and both caches updated.- Parameters:
request
- The request to obtain cookies from- Returns:
- A list of core
HttpCookie
s from the request. - See Also:
-
getApiCookies
public static <C> C[] getApiCookies(Request request, Class<C> cookieClass, Function<HttpCookie, C> convertor) Get the API specific cookies for a request. Internally the same caching/parsing is done as bygetCookies(Request)
and the coreHttpCookie
s are obtained. The passedconvertor
function is used to covert the coreHttpCookie
s to API specific cookies and the results cached along with the coreHttpCookie
s- Type Parameters:
C
- The class of the cookie API- Parameters:
request
- The request to get the cookies from.cookieClass
- The class of the cookie APIconvertor
- A function to convert from aHttpCookie
to an API cookie of typecookieClass
. The function may return null if the cookie is not compliant with the API.- Returns:
- An array of API specific cookies.
-
get
- Specified by:
get
in interfaceList<HttpCookie>
- Specified by:
get
in classAbstractList<HttpCookie>
-
size
public int size()- Specified by:
size
in interfaceCollection<HttpCookie>
- Specified by:
size
in interfaceList<HttpCookie>
- Specified by:
size
in classAbstractCollection<HttpCookie>
-
onComplianceViolation
Description copied from interface:ComplianceViolation.Listener
The compliance violation event.- Specified by:
onComplianceViolation
in interfaceComplianceViolation.Listener
- Parameters:
event
- the compliance violation event
-
addCookie
public void addCookie(String cookieName, String cookieValue, int cookieVersion, String cookieDomain, String cookiePath, String cookieComment) - Specified by:
addCookie
in interfaceCookieParser.Handler
-
parseCookies
public void parseCookies(HttpFields headers, ComplianceViolation.Listener complianceViolationListener) -
getApiCookies
-