All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class HTTPClient.CookieModule

java.lang.Object
    |
    +----HTTPClient.CookieModule

public class CookieModule
extends Object
implements HTTPClientModule, GlobalConstants
This module handles Netscape cookies (also called Version 0 cookies) and Version 1 cookies. Specifically is reads the Set-Cookie and Set-Cookie2 response headers and sets the Cookie and Cookie2 headers as neccessary.

The accepting and sending of cookies is controlled by a CookiePolicyHandler. This allows you to fine tune your privacy preferences. A cookie is only added to the cookie jar if the handler allows it, and a cookie from the cookie jar is only sent if the handler allows it.

The cookie jar is not yet persistent, i.e. all cookies are discarded at exit. Persistence will be added in the future.

Since:
V0.3
Version:
0.3 30/01/1998
Author:
Ronald Tschalär
See Also:
Netscape's cookie spec, HTTP State Management Mechanism spec

Method Index

 o discardAllCookies()
Discard all cookies for all contexts.
 o discardAllCookies(Object)
Discard all cookies for the given context.
 o requestHandler(Request, Response[])
Invoked by the HTTPClient.
 o responsePhase1Handler(Response, RoRequest)
Invoked by the HTTPClient.
 o responsePhase2Handler(Response, Request)
Invoked by the HTTPClient.
 o responsePhase3Handler(Response, RoRequest)
Invoked by the HTTPClient.
 o setCookiePolicyHandler(CookiePolicyHandler)
Sets a new cookie policy handler.
 o trailerHandler(Response, RoRequest)
Invoked by the HTTPClient.

Methods

 o requestHandler
public int requestHandler(Request req,
                          Response[] resp)
Invoked by the HTTPClient.

 o responsePhase1Handler
public void responsePhase1Handler(Response resp,
                                  RoRequest req) throws IOException
Invoked by the HTTPClient.

 o responsePhase2Handler
public int responsePhase2Handler(Response resp,
                                 Request req)
Invoked by the HTTPClient.

 o responsePhase3Handler
public void responsePhase3Handler(Response resp,
                                  RoRequest req)
Invoked by the HTTPClient.

 o trailerHandler
public void trailerHandler(Response resp,
                           RoRequest req) throws IOException
Invoked by the HTTPClient.

 o discardAllCookies
public static void discardAllCookies()
Discard all cookies for all contexts. Cookies stored in persistent storage are not affected.

 o discardAllCookies
public static void discardAllCookies(Object context)
Discard all cookies for the given context. Cookies stored in persistent storage are not affected.

Parameters:
context - the context Object
 o setCookiePolicyHandler
public static CookiePolicyHandler setCookiePolicyHandler(CookiePolicyHandler handler)
Sets a new cookie policy handler. This handler will be called for each cookie that a server wishes to set and for each cookie that this module wishes to send with a request. In either case the handler may allow or reject the operation.

At initialization time a default handler is installed. This handler allows all cookies to be sent. For any cookie that a server wishes to be set two lists are consulted. If the server matches any host or domain in the reject list then the cookie is rejected; if the server matches any host or domain in the accept list then the cookie is accepted. If no host or domain match is found in either of these two lists and user interaction is allowed then a dialog box is poped up to ask the user whether to accept or reject the cookie; if user interaction is not allowed the cookie is accepted.

The accept and reject lists in the default handler are initialized at startup from the two properties HTTPClient.cookies.hosts.accept and HTTPClient.cookies.hosts.reject. These properties must contain a "|" separated list of host and domain names. All names beginning with a "." are treated as domain names, all others as host names. An empty string which will match all hosts. The two lists are further expanded if the user chooses one of the "Accept All from Domain" or "Reject All from Domain" buttons in the dialog box.

Parameters:
the - new policy handler
Returns:
the previous policy handler

All Packages  Class Hierarchy  This Package  Previous  Next  Index