Class CookieCache
- All Implemented Interfaces:
Iterable<HttpCookie>, Collection<HttpCookie>, List<HttpCookie>, SequencedCollection<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
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.LoggerFields inherited from class AbstractList
modCountFields inherited from interface ComplianceViolation.Listener
NOOP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(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.voidThe compliance violation event.voidparseCookies(HttpFields headers, ComplianceViolation.Listener complianceViolationListener) intsize()Methods inherited from class AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface ComplianceViolation.Listener
initialize, onComplianceViolation, onRequestBegin, onRequestEndMethods inherited from interface List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, 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
HttpCookies 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 coreHttpCookies are obtained. The passedconvertorfunction is used to covert the coreHttpCookies to API specific cookies and the results cached along with the coreHttpCookies- 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 aHttpCookieto 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:
getin interfaceList<HttpCookie>- Specified by:
getin classAbstractList<HttpCookie>
-
size
public int size()- Specified by:
sizein interfaceCollection<HttpCookie>- Specified by:
sizein interfaceList<HttpCookie>- Specified by:
sizein classAbstractCollection<HttpCookie>
-
onComplianceViolation
Description copied from interface:ComplianceViolation.ListenerThe compliance violation event.- Specified by:
onComplianceViolationin interfaceComplianceViolation.Listener- Parameters:
event- the compliance violation event
-
addCookie
-
parseCookies
public void parseCookies(HttpFields headers, ComplianceViolation.Listener complianceViolationListener) -
getApiCookies
-