public class HttpState
extends java.lang.Object
A container for HTTP attributes that may persist from request
to request, such as cookies
and authentication
credentials
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PREEMPTIVE_DEFAULT
Deprecated.
This field and feature will be removed following HttpClient 3.0.
|
static java.lang.String |
PREEMPTIVE_PROPERTY
Deprecated.
This field and feature will be removed following HttpClient 3.0.
|
Constructor and Description |
---|
HttpState()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addCookie(Cookie cookie)
Adds an
HTTP cookie , replacing any existing equivalent cookies. |
void |
addCookies(Cookie[] cookies)
Adds an array of
HTTP cookies . |
void |
clear()
Clears the state information (all cookies, credentials and proxy credentials).
|
void |
clearCookies()
Clears all cookies.
|
void |
clearCredentials()
Clears all credentials.
|
void |
clearProxyCredentials()
Clears all proxy credentials.
|
int |
getCookiePolicy()
Deprecated.
Use
org.apache.commons.httpclient.params.HttpMethodParams#getCookiePolicy() ,
HttpMethod#getParams() . |
Cookie[] |
getCookies()
Returns an array of
cookies that this HTTP
state currently contains. |
Cookie[] |
getCookies(java.lang.String domain,
int port,
java.lang.String path,
boolean secure)
Deprecated.
use CookieSpec#match(String, int, String, boolean, Cookie)
|
Credentials |
getCredentials(AuthScope authscope)
Get the
credentials for the given authentication scope. |
Credentials |
getCredentials(java.lang.String realm,
java.lang.String host)
Deprecated.
use #getCredentials(AuthScope)
|
Credentials |
getProxyCredentials(AuthScope authscope)
Get the
proxy credentials for the given authentication scope. |
Credentials |
getProxyCredentials(java.lang.String realm,
java.lang.String proxyHost)
Deprecated.
use #getProxyCredentials(AuthScope)
|
boolean |
isAuthenticationPreemptive()
Deprecated.
Use
org.apache.commons.httpclient.params.HttpClientParams#isAuthenticationPreemptive() ,
HttpClient#getParams() . |
boolean |
purgeExpiredCookies()
Removes all of
cookies in this HTTP state
that have expired according to the current system time. |
boolean |
purgeExpiredCookies(java.util.Date date)
Removes all of
cookies in this HTTP state
that have expired by the specified date . |
void |
setAuthenticationPreemptive(boolean value)
Deprecated.
Use
org.apache.commons.httpclient.params.HttpClientParams#setAuthenticationPreemptive(boolean) ,
HttpClient#getParams() . |
void |
setCookiePolicy(int policy)
Deprecated.
Use
org.apache.commons.httpclient.params.HttpMethodParams#setCookiePolicy(String) ,
HttpMethod#getParams() . |
void |
setCredentials(AuthScope authscope,
Credentials credentials)
Sets the
credentials for the given authentication
scope. |
void |
setCredentials(java.lang.String realm,
java.lang.String host,
Credentials credentials)
Deprecated.
use #setCredentials(AuthScope, Credentials)
|
void |
setProxyCredentials(AuthScope authscope,
Credentials credentials)
Sets the
proxy credentials for the given authentication
realm. |
void |
setProxyCredentials(java.lang.String realm,
java.lang.String proxyHost,
Credentials credentials)
Deprecated.
use #setProxyCredentials(AuthScope, Credentials)
|
java.lang.String |
toString()
Returns a string representation of this HTTP state.
|
public static final java.lang.String PREEMPTIVE_PROPERTY
public static final java.lang.String PREEMPTIVE_DEFAULT
PREEMPTIVE_PROPERTY
.public void addCookie(Cookie cookie)
HTTP 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.cookie
- the cookie
to be addedaddCookies(Cookie[])
public void addCookies(Cookie[] cookies)
HTTP 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.cookies
- the cookies
to be addedaddCookie(Cookie)
public Cookie[] getCookies()
cookies
that this HTTP
state currently contains.cookies
.getCookies(String, int, String, boolean)
public Cookie[] getCookies(java.lang.String domain, int port, java.lang.String path, boolean secure)
cookies
in this HTTP
state that match the given request parameters.domain
- the request domainport
- the request portpath
- the request pathsecure
- true
when using HTTPScookies
.getCookies()
public boolean purgeExpiredCookies()
cookies
in this HTTP state
that have expired according to the current system time.purgeExpiredCookies(java.util.Date)
public boolean purgeExpiredCookies(java.util.Date date)
cookies
in this HTTP state
that have expired by the specified date
.date
- The date
to compare against.Cookie#isExpired(java.util.Date)
,
purgeExpiredCookies()
public int getCookiePolicy()
org.apache.commons.httpclient.params.HttpMethodParams#getCookiePolicy()
,
HttpMethod#getParams()
.cookie policy
for this
HTTP state.cookie policy
.public void setAuthenticationPreemptive(boolean value)
org.apache.commons.httpclient.params.HttpClientParams#setAuthenticationPreemptive(boolean)
,
HttpClient#getParams()
.value
- true if preemptive authentication should be
attempted, false otherwise.public boolean isAuthenticationPreemptive()
org.apache.commons.httpclient.params.HttpClientParams#isAuthenticationPreemptive()
,
HttpClient#getParams()
.public void setCookiePolicy(int policy)
org.apache.commons.httpclient.params.HttpMethodParams#setCookiePolicy(String)
,
HttpMethod#getParams()
.cookie policy
for this HTTP
state to one of the following supported policies:
CookiePolicy#COMPATIBILITY
,
CookiePolicy#NETSCAPE_DRAFT
or
CookiePolicy#RFC2109
.policy
- new cookie policy
public void setCredentials(java.lang.String realm, java.lang.String host, Credentials credentials)
credentials
for the given authentication
realm on the given host. The null
realm signifies default
credentials for the given host, which should be used when no
credentials
have been explictly supplied for the
challenging realm. The null
host signifies default
credentials, which should be used when no credentials
have been explictly supplied for the challenging host. Any previous
credentials for the given realm on the given host will be overwritten.realm
- the authentication realmhost
- the host the realm belongs tocredentials
- the authentication credentials
for the given realm.getCredentials(String, String)
,
setProxyCredentials(String, String, Credentials)
public void setCredentials(AuthScope authscope, Credentials credentials)
credentials
for the given authentication
scope. Any previous credentials for the given scope will be overwritten.authscope
- the authentication scope
credentials
- the authentication credentials
for the given scope.getCredentials(AuthScope)
,
setProxyCredentials(AuthScope, Credentials)
public Credentials getCredentials(java.lang.String realm, java.lang.String host)
credentials
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, return
null
.realm
- the authentication realmhost
- the host the realm is onsetCredentials(String, String, Credentials)
public Credentials getCredentials(AuthScope authscope)
credentials
for the given authentication scope.authscope
- the authentication scope
setCredentials(AuthScope, Credentials)
public void setProxyCredentials(java.lang.String realm, java.lang.String proxyHost, Credentials credentials)
credentials
for the given proxy authentication
realm on the given proxy host. The null
proxy realm signifies
default credentials for the given proxy host, which should be used when no
credentials
have been explictly supplied for the
challenging proxy realm. The null
proxy host signifies default
credentials, which should be used when no credentials
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.realm
- the authentication realmproxyHost
- the proxy hostcredentials
- the authentication credentials for the given realmgetProxyCredentials(AuthScope)
,
setCredentials(AuthScope, Credentials)
public void setProxyCredentials(AuthScope authscope, Credentials credentials)
proxy credentials
for the given authentication
realm. Any previous credentials for the given realm will be overwritten.authscope
- the authentication scope
credentials
- the authentication credentials
for the given realm.getProxyCredentials(AuthScope)
,
setCredentials(AuthScope, Credentials)
public Credentials getProxyCredentials(java.lang.String realm, java.lang.String proxyHost)
credentials
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, return
null
.realm
- the authentication realmproxyHost
- the proxy host the realm is onsetProxyCredentials(String, String, Credentials)
public Credentials getProxyCredentials(AuthScope authscope)
proxy credentials
for the given authentication scope.authscope
- the authentication scope
setProxyCredentials(AuthScope, Credentials)
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public void clearCredentials()
public void clearProxyCredentials()
public void clearCookies()
public void clear()
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"