|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.ibm.wbi.protocol.http.HttpCookie
Represent a cookie according to the Netscape specification (http://home.netscape.com/newsref/std/cookie_spec.html). Example usage in a RequestEditor's handleRequest method for creating a new cookie:
//...
HttpCookie cookie = new HttpCookie("mycookie", "foo");
DocumentInfo di = (DocumentInfo)e.getRequestInfo();
HttpRequestHeader hqh = di.getHttpRequestHeader();
addCookie(hqh, scookie);
//...
And for looking at an existing cookie, perhaps set by a server or
WBI generator.
//... DocumentInfo di = (DocumentInfo)e.getRequestInfo(); HttpRequestHeader hqh = di.getHttpRequestHeader(); HttpCookie cookie = getCookie(hqh, "mycookie"); if (cookie != null) value = cookie.getValue(); //...
| Field Summary | |
protected java.lang.String |
name
|
protected java.lang.String |
value
|
| Constructor Summary | |
HttpCookie(java.lang.String unparsed)
Creates a new HttpCookie instance based on the
unparsed string. |
|
HttpCookie(java.lang.String name,
java.lang.String value)
Creates a new HttpCookie instance. |
|
| Method Summary | |
static void |
addCookie(HttpRequestHeader h,
HttpCookie cookie)
Adds a Cookie to an HTTP header. |
static HttpCookie |
getCookie(HttpRequestHeader h)
Get the first Cookie header line in an HTTP header. |
static HttpCookie |
getCookie(HttpRequestHeader h,
java.lang.String name)
Get the first cookie in an HTTP header with a specified name. |
static java.util.Vector |
getCookies(HttpRequestHeader h)
Get all cookie header lines in an HTTP header. |
java.lang.String |
getName()
Get the name of the cookie |
java.lang.String |
getValue()
Get the value of the cookie |
static void |
setCookie(HttpRequestHeader h,
HttpCookie cookie)
Sets a value for the Cookie header line in an HTTP header, eliminating all previous values for the Cookie header. |
void |
setName(java.lang.String v)
Set the name of the cookie |
void |
setValue(java.lang.String v)
Set the value of the cookie |
java.lang.String |
toString()
Show the string representation of the cookie |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.lang.String name
protected java.lang.String value
| Constructor Detail |
public HttpCookie(java.lang.String unparsed)
HttpCookie instance based on the
unparsed string. Should the parsing fail, then some or all of
that string is ignored.unparsed - a String value
public HttpCookie(java.lang.String name,
java.lang.String value)
HttpCookie instance.name - The name of the cookievalue - The value of the cookie| Method Detail |
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getName()
public void setName(java.lang.String v)
v - The new namepublic java.lang.String getValue()
public void setValue(java.lang.String v)
v - The new value for the cookiepublic static HttpCookie getCookie(HttpRequestHeader h)
h - The HttpRequestHeader.HttpCookie, or null if there are
none.
public static HttpCookie getCookie(HttpRequestHeader h,
java.lang.String name)
h - The HttpRequestHeader.name - The name to look for (case-sensitive).HttpCookie.public static java.util.Vector getCookies(HttpRequestHeader h)
h - The HttpRequestHeader.HttpCookies.
public static void setCookie(HttpRequestHeader h,
HttpCookie cookie)
h - The HttpRequestHeader.cookie - The value to set.
public static void addCookie(HttpRequestHeader h,
HttpCookie cookie)
h - The HttpRequestHeader.cookie - The value to add.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||