public class CookieManager extends Object implements Serializable
WebClient
. This class is thread-safe.Modifier and Type | Field and Description |
---|---|
static String |
HTMLUNIT_COOKIE_POLICY
HtmlUnit's cookie policy is to be browser-compatible.
|
Constructor and Description |
---|
CookieManager()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addCookie(Cookie cookie)
Adds the specified cookie.
|
void |
clearCookies()
Removes all cookies.
|
Cookie |
getCookie(String name)
Returns the currently configured cookie with the specified name, or null if one does not exist.
|
Set<Cookie> |
getCookies()
Returns the currently configured cookies, in an unmodifiable set.
|
Set<Cookie> |
getCookies(URL url)
Returns the currently configured cookies applicable to the specified URL, in an unmodifiable set.
|
protected int |
getPort(URL url)
Gets the port of the URL.
|
boolean |
isCookiesEnabled()
Returns true if cookies are enabled.
|
void |
removeCookie(Cookie cookie)
Removes the specified cookie.
|
void |
setCookiesEnabled(boolean enabled)
Enables/disables cookie support.
|
protected void |
updateFromState(org.apache.http.client.CookieStore state)
Updates the current cookie settings from the specified HTTP state's cookie configuration.
|
protected void |
updateState(org.apache.http.client.CookieStore state)
Updates the specified HTTP state's cookie configuration according to the current cookie settings.
|
public static final String HTMLUNIT_COOKIE_POLICY
CookiePolicy
constants directly.public void setCookiesEnabled(boolean enabled)
enabled
- true to enable cookie support, false otherwisepublic boolean isCookiesEnabled()
public Set<Cookie> getCookies()
public Set<Cookie> getCookies(URL url)
url
- the URL on which to filter the returned cookiesprotected int getPort(URL url)
url
- the URLpublic Cookie getCookie(String name)
name
- the name of the cookie to returnpublic void addCookie(Cookie cookie)
cookie
- the cookie to addpublic void removeCookie(Cookie cookie)
cookie
- the cookie to removepublic void clearCookies()
protected void updateState(org.apache.http.client.CookieStore state)
state
- the HTTP state to updateupdateFromState(CookieStore)
protected void updateFromState(org.apache.http.client.CookieStore state)
state
- the HTTP state to update fromupdateState(CookieStore)
Copyright © 2002-2012 Gargoyle Software Inc.. All Rights Reserved.