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(org.apache.commons.httpclient.Cookie cookie)
Adds the specified cookie.
|
void |
clearCookies()
Removes all cookies.
|
org.apache.commons.httpclient.Cookie |
getCookie(String name)
Returns the currently configured cookie with the specified name, or null if one does not exist.
|
Set<org.apache.commons.httpclient.Cookie> |
getCookies()
Returns the currently configured cookies, in an unmodifiable set.
|
Set<org.apache.commons.httpclient.Cookie> |
getCookies(String domain)
Returns the currently configured cookies for the specified domain, in an unmodifiable set.
|
boolean |
isCookiesEnabled()
Returns true if cookies are enabled.
|
void |
removeCookie(org.apache.commons.httpclient.Cookie cookie)
Removes the specified cookie.
|
void |
setCookiesEnabled(boolean enabled)
Enables/disables cookie support.
|
protected void |
updateFromState(org.apache.commons.httpclient.HttpState state)
Updates the current cookie settings from the specified HTTP state's cookie configuration.
|
protected void |
updateState(org.apache.commons.httpclient.HttpState 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<org.apache.commons.httpclient.Cookie> getCookies()
public Set<org.apache.commons.httpclient.Cookie> getCookies(String domain)
domain
- the domain on which to filter the returned cookiespublic org.apache.commons.httpclient.Cookie getCookie(String name)
name
- the name of the cookie to returnpublic void addCookie(org.apache.commons.httpclient.Cookie cookie)
cookie
- the cookie to addpublic void removeCookie(org.apache.commons.httpclient.Cookie cookie)
cookie
- the cookie to removepublic void clearCookies()
protected void updateState(org.apache.commons.httpclient.HttpState state)
state
- the HTTP state to updateupdateFromState(HttpState)
protected void updateFromState(org.apache.commons.httpclient.HttpState state)
state
- the HTTP state to update fromupdateState(HttpState)
Copyright © 2002–2014 Gargoyle Software Inc.. All rights reserved.