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
FieldsModifier and TypeFieldDescriptionstatic final CookieJarA cookie jar that never accepts any cookies. -
Method Summary
Modifier and TypeMethodDescriptionloadForRequest(UnoUrl url) Loads cookies from this jar for an HTTP request tourl.voidsaveFromResponse(UnoUrl url, List<Cookie> cookies) Savescookiesfrom an HTTP response to this store, according to this jar's policy.
-
Field Details
-
NO_COOKIES
A cookie jar that never accepts any cookies.
-
-
Method Details
-
saveFromResponse
Savescookiesfrom 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,cookiescontains only the trailer's cookies.- Parameters:
url- The URL of the response.cookies- The list of cookies to save.
-
loadForRequest
Loads cookies from this jar for an HTTP request tourl. 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 matchurl.- Parameters:
url- The URL of the request.- Returns:
- The list of cookies to include in the request.
-