org.apache.http.client
Class HttpState

java.lang.Object
  extended by org.apache.http.client.HttpState

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.

Version:
$Revision: 555245 $ $Date: 2007-07-11 13:14:49 +0200 (Wed, 11 Jul 2007) $
Author:
Remy Maucherat, Rodney Waldhoff, Jeff Dever, Sean C. Sullivan, Michael Becke, Oleg Kalnichevski, Mike Bowler, Adrian Sutton

Constructor Summary
HttpState()
          Default constructor.
 
Method Summary
 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.
 Cookie[] getCookies()
          Returns an array of cookies that this HTTP state currently contains.
 Credentials getCredentials(AuthScope authscope)
          Get the credentials for the given authentication scope.
 boolean purgeExpiredCookies()
          Removes all of cookies in this HTTP state that have expired by the specified date.
 void setCredentials(AuthScope authscope, Credentials credentials)
          Sets the credentials for the given authentication scope.
 java.lang.String toString()
          Returns a string representation of this HTTP state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpState

public HttpState()
Default constructor.

Method Detail

addCookie

public void addCookie(Cookie cookie)
Adds an 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.

Parameters:
cookie - the cookie to be added
See Also:
addCookies(Cookie[])

addCookies

public void addCookies(Cookie[] cookies)
Adds an array of 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.

Parameters:
cookies - the cookies to be added
See Also:
addCookie(Cookie)

getCookies

public Cookie[] getCookies()
Returns an array of cookies that this HTTP state currently contains.

Returns:
an array of cookies.

purgeExpiredCookies

public boolean purgeExpiredCookies()
Removes all of cookies in this HTTP state that have expired by the specified date.

Returns:
true if any cookies were purged.
See Also:
Cookie.isExpired(Date)

setCredentials

public void setCredentials(AuthScope authscope,
                           Credentials credentials)
Sets the credentials for the given authentication scope. Any previous credentials for the given scope will be overwritten.

Parameters:
authscope - the authentication scope
credentials - the authentication credentials for the given scope.
See Also:
getCredentials(AuthScope)

getCredentials

public Credentials getCredentials(AuthScope authscope)
Get the credentials for the given authentication scope.

Parameters:
authscope - the authentication scope
Returns:
the credentials
See Also:
setCredentials(AuthScope, Credentials)

toString

public java.lang.String toString()
Returns a string representation of this HTTP state.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the HTTP state.
See Also:
Object.toString()

clearCredentials

public void clearCredentials()
Clears all credentials.


clearCookies

public void clearCookies()
Clears all cookies.


clear

public void clear()
Clears the state information (all cookies, credentials and proxy credentials).



Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.