Class CookieCache

java.lang.Object
java.util.AbstractCollection<org.eclipse.jetty.http.HttpCookie>
java.util.AbstractList<org.eclipse.jetty.http.HttpCookie>
org.eclipse.jetty.server.CookieCache
All Implemented Interfaces:
Iterable<org.eclipse.jetty.http.HttpCookie>, Collection<org.eclipse.jetty.http.HttpCookie>, List<org.eclipse.jetty.http.HttpCookie>, SequencedCollection<org.eclipse.jetty.http.HttpCookie>, org.eclipse.jetty.http.ComplianceViolation.Listener, org.eclipse.jetty.http.CookieParser.Handler

public class CookieCache extends AbstractList<org.eclipse.jetty.http.HttpCookie> implements org.eclipse.jetty.http.CookieParser.Handler, org.eclipse.jetty.http.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 Details

    • LOG

      protected static final org.slf4j.Logger LOG
    • _rawFields

      protected final List<String> _rawFields
  • Constructor Details

    • CookieCache

      public CookieCache()
    • CookieCache

      public CookieCache(org.eclipse.jetty.http.CookieCompliance compliance)
  • Method Details

    • getCookies

      public static List<org.eclipse.jetty.http.HttpCookie> getCookies(Request request)
      Get the core HttpCookies for a request. Cookies may be cached as a request attribute, failing that they may be cached in the Component 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<org.eclipse.jetty.http.HttpCookie,C> convertor)
      Get the API specific cookies for a request. Internally the same caching/parsing is done as by getCookies(Request) and the core HttpCookies are obtained. The passed convertor function is used to covert the core HttpCookies to API specific cookies and the results cached along with the core HttpCookies
      Type Parameters:
      C - The class of the cookie API
      Parameters:
      request - The request to get the cookies from.
      cookieClass - The class of the cookie API
      convertor - A function to convert from a HttpCookie to an API cookie of type cookieClass. The function may return null if the cookie is not compliant with the API.
      Returns:
      An array of API specific cookies.
    • get

      public org.eclipse.jetty.http.HttpCookie get(int index)
      Specified by:
      get in interface List<org.eclipse.jetty.http.HttpCookie>
      Specified by:
      get in class AbstractList<org.eclipse.jetty.http.HttpCookie>
    • size

      public int size()
      Specified by:
      size in interface Collection<org.eclipse.jetty.http.HttpCookie>
      Specified by:
      size in interface List<org.eclipse.jetty.http.HttpCookie>
      Specified by:
      size in class AbstractCollection<org.eclipse.jetty.http.HttpCookie>
    • onComplianceViolation

      public void onComplianceViolation(org.eclipse.jetty.http.ComplianceViolation.Event event)
      Specified by:
      onComplianceViolation in interface org.eclipse.jetty.http.ComplianceViolation.Listener
    • addCookie

      public void addCookie(String cookieName, String cookieValue, int cookieVersion, String cookieDomain, String cookiePath, String cookieComment)
      Specified by:
      addCookie in interface org.eclipse.jetty.http.CookieParser.Handler
    • parseCookies

      public void parseCookies(org.eclipse.jetty.http.HttpFields headers, org.eclipse.jetty.http.ComplianceViolation.Listener complianceViolationListener)
    • getApiCookies

      public <C> C[] getApiCookies(Class<C> apiClass, Function<org.eclipse.jetty.http.HttpCookie,C> convertor)