Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.commons.httpclient.HttpState
public class HttpState
extends java.lang.Object
cookies
and authentication
credentials
.
Field Summary | |
static String |
|
static String |
|
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
int |
|
Cookie[] |
|
Cookie[] |
|
Credentials |
|
Credentials |
|
Credentials |
|
Credentials |
|
boolean | |
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
String |
|
public static final String PREEMPTIVE_DEFAULT
Deprecated. This field and feature will be removed following HttpClient 3.0.
The default value forPREEMPTIVE_PROPERTY
.
public static final String PREEMPTIVE_PROPERTY
Deprecated. This field and feature will be removed following HttpClient 3.0.
The boolean system property name to turn on preemptive authentication.
public void addCookie(Cookie cookie)
Adds anHTTP cookie
, replacing any existing equivalent cookies. If the given cookie has already expired it will not be added, but existing values will still be removed.
- Parameters:
cookie
- thecookie
to be added
- See Also:
addCookies(Cookie[])
public void addCookies(Cookie[] cookies)
Adds an array ofHTTP cookies
. Cookies are added individually and in the given array order. If any of the given cookies has already expired it will not be added, but existing values will still be removed.
- Parameters:
cookies
- thecookies
to be added
- See Also:
addCookie(Cookie)
public void clear()
Clears the state information (all cookies, credentials and proxy credentials).
public void clearCookies()
Clears all cookies.
public void clearCredentials()
Clears all credentials.
public void clearProxyCredentials()
Clears all proxy credentials.
public int getCookiePolicy()
Deprecated. Use
HttpMethodParams.getCookiePolicy()
,HttpMethod.getParams()
.Returns the currentcookie policy
for this HTTP state.
- Returns:
- The
cookie policy
.
public Cookie[] getCookies()
Returns an array ofcookies
that this HTTP state currently contains.
- Returns:
- an array of
cookies
.
public Cookie[] getCookies(String domain, int port, String path, boolean secure)
Deprecated. use CookieSpec#match(String, int, String, boolean, Cookie)
Returns an array ofcookies
in this HTTP state that match the given request parameters.
- Parameters:
domain
- the request domainport
- the request portpath
- the request pathsecure
-true
when using HTTPS
- Returns:
- an array of
cookies
.
- See Also:
getCookies()
public Credentials getCredentials(String realm, String host)
Deprecated. use #getCredentials(AuthScope)
Get thecredentials
for the given authentication scope on the given host. If the realm exists on host, return the coresponding credentials. If the host exists with a null realm, return the corresponding credentials. If the realm exists with a null host, return the corresponding credentials. If the realm does not exist, return the default Credentials. If there are no default credentials, returnnull
.
- Parameters:
realm
- the authentication realmhost
- the host the realm is on
- Returns:
- the credentials
public Credentials getCredentials(AuthScope authscope)
Get thecredentials
for the given authentication scope.
- Parameters:
authscope
- theauthentication scope
- Returns:
- the credentials
- Since:
- 3.0
public Credentials getProxyCredentials(String realm, String proxyHost)
Deprecated. use #getProxyCredentials(AuthScope)
Get thecredentials
for the proxy host with the given authentication scope. If the realm exists on host, return the coresponding credentials. If the host exists with a null realm, return the corresponding credentials. If the realm exists with a null host, return the corresponding credentials. If the realm does not exist, return the default Credentials. If there are no default credentials, returnnull
.
- Parameters:
realm
- the authentication realmproxyHost
- the proxy host the realm is on
- Returns:
- the credentials
public Credentials getProxyCredentials(AuthScope authscope)
Get theproxy credentials
for the given authentication scope.
- Parameters:
authscope
- theauthentication scope
- Returns:
- the credentials
- Since:
- 3.0
public boolean isAuthenticationPreemptive()
Deprecated. Use
HttpClientParams.isAuthenticationPreemptive()
,HttpClient.getParams()
.Returns true if preemptive authentication should be attempted, false otherwise.
- Returns:
- boolean flag.
public boolean purgeExpiredCookies()
Removes all ofcookies
in this HTTP state that have expired according to the current system time.
- See Also:
purgeExpiredCookies(java.util.Date)
public boolean purgeExpiredCookies(Date date)
Removes all ofcookies
in this HTTP state that have expired by the specifieddate
.
- Parameters:
date
- Thedate
to compare against.
- Returns:
- true if any cookies were purged.
- See Also:
Cookie.isExpired(java.util.Date)
,purgeExpiredCookies()
public void setAuthenticationPreemptive(boolean value)
Deprecated. Use
HttpClientParams.setAuthenticationPreemptive(boolean)
,HttpClient.getParams()
.Defines whether preemptive authentication should be attempted.
- Parameters:
value
- true if preemptive authentication should be attempted, false otherwise.
public void setCookiePolicy(int policy)
Deprecated. Use
HttpMethodParams.setCookiePolicy(String)
,HttpMethod.getParams()
.Sets the currentcookie policy
for this HTTP state to one of the following supported policies:CookiePolicy.COMPATIBILITY
,CookiePolicy.NETSCAPE_DRAFT
orCookiePolicy.RFC2109
.
- Parameters:
policy
- newcookie policy
public void setCredentials(String realm, String host, Credentials credentials)
Deprecated. use #setCredentials(AuthScope, Credentials)
Sets thecredentials
for the given authentication realm on the given host. Thenull
realm signifies default credentials for the given host, which should be used when nocredentials
have been explictly supplied for the challenging realm. Thenull
host signifies default credentials, which should be used when nocredentials
have been explictly supplied for the challenging host. Any previous credentials for the given realm on the given host will be overwritten.
- Parameters:
realm
- the authentication realmhost
- the host the realm belongs tocredentials
- the authenticationcredentials
for the given realm.
public void setCredentials(AuthScope authscope, Credentials credentials)
Sets thecredentials
for the given authentication scope. Any previous credentials for the given scope will be overwritten.
- Parameters:
authscope
- theauthentication scope
credentials
- the authenticationcredentials
for the given scope.
- Since:
- 3.0
public void setProxyCredentials(String realm, String proxyHost, Credentials credentials)
Deprecated. use #setProxyCredentials(AuthScope, Credentials)
Sets thecredentials
for the given proxy authentication realm on the given proxy host. Thenull
proxy realm signifies default credentials for the given proxy host, which should be used when nocredentials
have been explictly supplied for the challenging proxy realm. Thenull
proxy host signifies default credentials, which should be used when nocredentials
have been explictly supplied for the challenging proxy host. Any previous credentials for the given proxy realm on the given proxy host will be overwritten.
- Parameters:
realm
- the authentication realmproxyHost
- the proxy hostcredentials
- the authentication credentials for the given realm
public void setProxyCredentials(AuthScope authscope, Credentials credentials)
Sets theproxy credentials
for the given authentication realm. Any previous credentials for the given realm will be overwritten.
- Parameters:
authscope
- theauthentication scope
credentials
- the authenticationcredentials
for the given realm.
- Since:
- 3.0
public String toString()
Returns a string representation of this HTTP state.
- Returns:
- The string representation of the HTTP state.
- See Also:
java.lang.Object.toString()