|
Agent System POND 1.0 (1.7.2000) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--FIM.Util.WWW.Cookies.CookieStore
A store for cookies. Adheres to the standard (number of cookies, size, ...) as defined in the Cookie definition (http://home.netscape.com/newsref/std/cookie_spec.html).
Sample code for usage (simplified and without exception handling):
private CookieStore cookies=new CookieStore(); ... URL url=new URL(...); HttpURLConnection con=(HttpURLConnection)url.openConnection(); con.setRequestProperty(...); cookies.sendCookies(con,false); con.connect(); PrintWriter out=new PrintWriter(con.getOutputStream()); out.println(...); out.close(); if(con.getResponseCode()!=200) throw new ...Exception(); cookies.parseCookies(con); BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream())); String line=in.readLine(); ...
CookieEnumeration
, Serialized FormField Summary | |
static int |
COOKIES_PER_DOMAIN
The maximum number of cookies stored from one domain (exact match: "www.acme.com" and "acme.com" receive each 20 cookies) |
protected Hashtable |
table
Store for the cookies. |
static int |
TOTAL_COOKIES
The maximum number of cookies stored in total. |
Constructor Summary | |
CookieStore()
Creates a new empty store for cookies. |
Method Summary | |
void |
clearCookies()
Removes all cookies from the store. |
protected void |
enforceLimits(String domain)
Removes all expired cookies form the store. |
Cookie |
getCookie(String name,
String domain,
String path)
Retrieve a certain cookie from the store. |
CookieEnumeration |
getCookies(String domain,
String path)
Returns all cookies which match a specified domain and path. |
void |
parseCookies(HttpURLConnection con)
Retrieves all cookies from a HttpURLConnection and stores them. |
void |
sendCookies(HttpURLConnection con,
boolean secureConn)
Sends all matching cookies to a HttpURLConnection . |
Cookie |
setCookie(Cookie c)
Puts a certain cookie into the store and enforces the limits. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int TOTAL_COOKIES
public static final int COOKIES_PER_DOMAIN
protected Hashtable table
Constructor Detail |
public CookieStore()
Method Detail |
public void clearCookies()
public void parseCookies(HttpURLConnection con)
HttpURLConnection
and stores them.con
- the connection to retrieve the cookies from. Must already be connected.public void sendCookies(HttpURLConnection con, boolean secureConn)
HttpURLConnection
.con
- the connection to retrieve the cookies from. May not be connected!secureConn
- whether this is a secure connection (cookies marked as secure will be sent) or notprotected void enforceLimits(String domain)
domain
- the domain to check the limit forpublic CookieEnumeration getCookies(String domain, String path)
null
,
all cookies will match it.domain
- the domain the returned cookies are from (if null
ignored)path
- the path the returned cookies are valid for (if null
ignored)public Cookie getCookie(String name, String domain, String path)
name
- the name of the cookiedomain
- the domain the cookie is frompath
- the path the cookie is valid for (if "" or null
, "/" is used)null
if not foundpublic Cookie setCookie(Cookie c)
c
- the cookie to storenull
if new
|
Agent System POND 1.0 (1.7.2000) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |