Module bus.http

Interface CookieJar


public interface CookieJar
Provides a policy and persistence for HTTP cookies.

As a policy, implementations of this interface are responsible for selecting which cookies to accept and reject. A reasonable policy is to reject all cookies, though this may interfere with session-based authentication schemes that require cookies.

Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CookieJar
    A cookie jar that never accepts any cookies.
  • Method Summary

    Modifier and Type
    Method
    Description
    Loads cookies from this jar for an HTTP request to url.
    void
    Saves cookies from an HTTP response to this store, according to this jar's policy.
  • Field Details

    • NO_COOKIES

      static final CookieJar NO_COOKIES
      A cookie jar that never accepts any cookies.
  • Method Details

    • saveFromResponse

      void saveFromResponse(UnoUrl url, List<Cookie> cookies)
      Saves cookies from an HTTP response to this store, according to this jar's policy. Note that this method may be called a second time for a single HTTP response if that response includes a trailer. For this obscure HTTP feature, cookies contains only the trailer's cookies.
      Parameters:
      url - The URL of the response.
      cookies - The list of cookies to save.
    • loadForRequest

      List<Cookie> loadForRequest(UnoUrl url)
      Loads cookies from this jar for an HTTP request to url. This method returns a possibly empty list of cookies for the network request. A simple implementation will return accepted cookies that have not yet expired and that match url.
      Parameters:
      url - The URL of the request.
      Returns:
      The list of cookies to include in the request.