org.apache.commons.httpclient
Class HttpState

java.lang.Object
  |
  +--org.apache.commons.httpclient.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: 1.4 $ $Date: 2001/10/06 00:21:27 $
Author:
Remy Maucherat, Rodney Waldhoff

Constructor Summary
HttpState()
           
 
Method Summary
 void addCookie(Cookie cookie)
          Add a cookie.
 void addCookies(Cookie[] newcookies)
          Add zero or more cookies If any given cookie has already expired, deletes the corresponding existing cookie (if any).
 Cookie[] getCookies()
          Obtain an array of my Cookies.
 Cookie[] getCookies(java.lang.String domain, int port, java.lang.String path, boolean secure, java.util.Date now)
          Obtain an array of my Cookies that match the given request parameters.
 Credentials getCredentials(java.lang.String realm)
           Get the Credentials for the given authentication realm.
 boolean purgeExpiredCookies()
          Remove all of my Cookies that have expired according to the current system time.
 boolean purgeExpiredCookies(java.util.Date date)
          Remove all of my Cookies that have expired by the specified date.
 void setCredentials(java.lang.String realm, Credentials credentials)
           Set the Credentials for the given authentication realm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpState

public HttpState()
Method Detail

addCookie

public void addCookie(Cookie cookie)
Add a cookie. If the given cookie has already expired, deletes the corresponding existing cookie (if any).
Parameters:
cookie - the Cookie to add

addCookies

public void addCookies(Cookie[] newcookies)
Add zero or more cookies If any given cookie has already expired, deletes the corresponding existing cookie (if any).
Parameters:
newcookies - the Cookies to add

getCookies

public Cookie[] getCookies()
Obtain an array of my Cookies.
Returns:
an array of my Cookies.

getCookies

public Cookie[] getCookies(java.lang.String domain,
                           int port,
                           java.lang.String path,
                           boolean secure,
                           java.util.Date now)
Obtain an array of my Cookies that match the given request parameters.
Parameters:
domain - the request domain
port - the request port
path - the request path
secure - true when using HTTPS
now - the Date by which expiration is determined
Returns:
an array of my Cookies.
See Also:
Cookie.matches(java.lang.String, int, java.lang.String, boolean, java.util.Date)

purgeExpiredCookies

public boolean purgeExpiredCookies()
Remove all of my Cookies that have expired according to the current system time.
See Also:
purgeExpiredCookies(java.util.Date)

purgeExpiredCookies

public boolean purgeExpiredCookies(java.util.Date date)
Remove all of my Cookies that have expired by the specified date.
See Also:
Cookie.isExpired(java.util.Date)

setCredentials

public void setCredentials(java.lang.String realm,
                           Credentials credentials)

Set the Credentials for the given authentication realm.

When realm is null, I'll use the given credentials when no other Credentials have been supplied for the given challenging realm. (I.e., use a null realm to set the "default" credentials.)

Parameters:
realm - the authentication realm
credentials - the authentication credentials for the given realm

getCredentials

public Credentials getCredentials(java.lang.String realm)

Get the Credentials for the given authentication realm.

When realm is null, I'll return the "default" credentials. (See setCredentials.)

Parameters:
realm - the authentication realm


Copyright (c) 2001 - Apache Software Foundation