All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----HTTPClient.CookieModule
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 list if the handler allows it, and a cookie from the cookie list is only sent if the handler allows it.
A cookie jar can be used to store cookies between sessions. This file is read when this class is loaded and is written when the application exits; only cookies from the default context are saved. The name of the file is controlled by the system property HTTPClient.cookies.jar and defaults to a system dependent name. The reading and saving of cookies is enabled by setting the system property HTTPClient.cookies.save to true.
public int requestHandler(Request req,
Response resp[])
public void responsePhase1Handler(Response resp,
RoRequest req) throws IOException
public int responsePhase2Handler(Response resp,
Request req)
public void responsePhase3Handler(Response resp,
RoRequest req)
public void trailerHandler(Response resp,
RoRequest req) throws IOException
public static void discardAllCookies()
public static void discardAllCookies(Object context)
public static Cookie[] listAllCookies()
public static Cookie[] listAllCookies(Object context)
public static void addCookie(Cookie cookie)
public static void addCookie(Cookie cookie,
Object context)
public static void removeCookie(Cookie cookie)
public static void removeCookie(Cookie cookie,
Object context)
public static synchronized CookiePolicyHandler setCookiePolicyHandler(CookiePolicyHandler handler)
CookieModule.setCookiePolicyHandler(null);.
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 (in that order). 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.
Note: the default handler does not implement the rules concerning unverifiable transactions (section 4.3.5, RFC-2109). The reason for this is simple: the default handler knows nothing about the application using this client, and it therefore does not have enough information to determine when a request is verifiable and when not. You are therefore encouraged to provide your own handler which implements section 4.3.5 (use the CookiePolicyHandler.sendCookie method for this).
All Packages Class Hierarchy This Package Previous Next Index