Module org.htmlunit

Class HtmlUnitSameSiteCookieStore

java.lang.Object
org.htmlunit.httpclient.HtmlUnitSameSiteCookieStore
All Implemented Interfaces:
org.apache.http.client.CookieStore

public final class HtmlUnitSameSiteCookieStore extends Object implements org.apache.http.client.CookieStore
A CookieStore used for one request; returns only the cookies that are allowed by their SameSite attribute (all other operations are delegated).

Like the browsers, for a cross-site request

  • 'None' cookies are always sent (they are secure, see HtmlUnitSameSiteHandler)
  • 'Strict' cookies are never sent
  • 'Lax' cookies are only sent for top-level navigations with a safe method (e.g. GET)
  • cookies without (or with an invalid) SameSite attribute are handled as 'Lax'; additionally they are sent for top-level navigations with an unsafe method (e.g. POST) within two minutes after they were created (Lax-allowing-unsafe)
Author:
Ronald Brill
See Also:
  • Constructor Details

    • HtmlUnitSameSiteCookieStore

      public HtmlUnitSameSiteCookieStore(org.apache.http.client.CookieStore delegate, boolean topLevelNavigation, boolean safeMethod)
      Ctor.
      Parameters:
      delegate - the cookie store providing all cookies
      topLevelNavigation - whether the (cross-site) request is a top-level navigation
      safeMethod - whether the request uses a safe method (GET, HEAD, OPTIONS, TRACE)
  • Method Details

    • addCookie

      public void addCookie(org.apache.http.cookie.Cookie cookie)
      Specified by:
      addCookie in interface org.apache.http.client.CookieStore
    • getCookies

      public List<org.apache.http.cookie.Cookie> getCookies()
      Returns the cookies that are allowed to be sent with this cross-site request.
      Specified by:
      getCookies in interface org.apache.http.client.CookieStore
    • clearExpired

      public boolean clearExpired(Date date)
      Specified by:
      clearExpired in interface org.apache.http.client.CookieStore
    • clear

      public void clear()
      Specified by:
      clear in interface org.apache.http.client.CookieStore