Package rife.engine
Class SiteCookieJar
java.lang.Object
rife.engine.SiteCookieJar
Acts as the browser for the cookies of a
SiteRunner. It
keeps the cookies that the responses set and sends them back with the
requests they apply to, by host, domain, path, expiry and secure flag.
When the web view of your application keeps the cookies of the origin
itself, you don't need a jar. With a SiteCookieStore, the cookies
that have an expiry also survive a restart of your application, which is
useful for a remembered login for instance.
Cookies that are set for a domain are also sent to its subdomains. Since the list of public suffixes isn't known here, a jar shouldn't be shared by origins that don't trust each other.
A jar can be used from several threads at the same time.
- Since:
- 1.11.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a jar that keeps its cookies in memory only.SiteCookieJar(SiteCookieStore store) Creates a jar that restores its cookies from a store and saves the ones that last there each time they change. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all the cookies.Retrieves all the cookies that haven't expired.getCookies(String host, String path, boolean secure) Retrieves the cookies that would be sent with a request, ordered with the longest path first.
-
Constructor Details
-
SiteCookieJar
public SiteCookieJar()Creates a jar that keeps its cookies in memory only.- Since:
- 1.11.0
-
SiteCookieJar
Creates a jar that restores its cookies from a store and saves the ones that last there each time they change.- Parameters:
store- the store of the cookies, ornullto keep them in memory only- Since:
- 1.11.0
-
-
Method Details
-
getCookies
Retrieves all the cookies that haven't expired.- Returns:
- the cookies of this jar
- Since:
- 1.11.0
-
getCookies
Retrieves the cookies that would be sent with a request, ordered with the longest path first.- Parameters:
host- the host of the requestpath- the path of the requestsecure- whether the request is secure- Returns:
- the matching cookies
- Since:
- 1.11.0
-
clear
public void clear()Removes all the cookies.- Since:
- 1.11.0
-