|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.httpclient.NameValuePair | +--org.apache.commons.httpclient.Cookie
An HTTP "magic-cookie", as specified in RFC 2109.
Constructor Summary | |
Cookie(java.lang.String domain,
java.lang.String name,
java.lang.String value)
Create a cookie. |
|
Cookie(java.lang.String domain,
java.lang.String name,
java.lang.String value,
java.lang.String path,
java.util.Date expires,
boolean secure)
Create a cookie. |
|
Cookie(java.lang.String domain,
java.lang.String name,
java.lang.String value,
java.lang.String path,
int maxAge,
boolean secure)
Create a cookie. |
Method Summary | |
static Header |
createCookieHeader(java.lang.String domain,
int port,
java.lang.String path,
boolean secure,
Cookie[] cookies)
Create a Cookie header containing all non-expired cookies in cookies, associated with the given domain, port, path and https setting. |
static Header |
createCookieHeader(java.lang.String domain,
int port,
java.lang.String path,
boolean secure,
java.util.Date now,
Cookie[] cookies)
Create a Cookie header containing all cookies in cookies, associated with the given domain, port, path and https setting, and which are not expired according to the given date. |
static Header |
createCookieHeader(java.lang.String domain,
java.lang.String path,
boolean secure,
Cookie[] cookies)
Deprecated. use the version which includes port number and date |
static Header |
createCookieHeader(java.lang.String domain,
java.lang.String path,
Cookie[] cookies)
Create a Cookie header containing all non-expired cookies in cookies, associated with the given domain and path, assuming the connection is not secure. |
boolean |
equals(java.lang.Object obj)
Two cookies are equal if the name, path and domain match. |
java.lang.String |
getComment()
Returns the comment describing the purpose of this cookie, or null if no such comment has been defined. |
java.lang.String |
getDomain()
Returns my domain. |
java.util.Date |
getExpiryDate()
Returns my expiration Date , or null
if none exists. |
java.lang.String |
getPath()
Return my path. |
boolean |
getSecure()
Return whether this cookie should only be sent over secure connections. |
int |
getVersion()
Return the version of the HTTP cookie specification I use. |
int |
hashCode()
Returns a hash code in keeping with the general hashCode contract . |
boolean |
isExpired()
Return true if I have expired. |
boolean |
isExpired(java.util.Date now)
Return true if I have expired. |
boolean |
isPersistent()
Returns false if I should be discarded at the end of the "session"; true otherwise. |
boolean |
matches(java.lang.String domain,
int port,
java.lang.String path,
boolean secure)
Return true if I should be submitted with a request with given attributes, false otherwise. |
boolean |
matches(java.lang.String domain,
int port,
java.lang.String path,
boolean secure,
java.util.Date now)
Return true if I should be submitted with a request with given attributes, false otherwise. |
static Cookie[] |
parse(java.lang.String domain,
int port,
java.lang.String path,
boolean secure,
Header setCookie)
Parses the Set-Cookie Header into an array of
Cookies. |
static Cookie[] |
parse(java.lang.String domain,
int port,
java.lang.String path,
Header setCookie)
Parses the Set-Cookie Header into an array of
Cookies, assuming that the cookies were recieved
on an insecure channel. |
static Cookie[] |
parse(java.lang.String domain,
java.lang.String path,
boolean secure,
Header setCookie)
Parses the Set-Cookie Header into an array of
Cookies. |
static Cookie[] |
parse(java.lang.String domain,
java.lang.String path,
Header setCookie)
Parses the Set-Cookie Header into an array of
Cookies, assuming that the cookies were recieved
on an insecure channel. |
void |
setComment(java.lang.String comment)
If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment. |
void |
setDomain(java.lang.String domain)
Sets my domain. |
void |
setExpiryDate(java.util.Date expiryDate)
Expiration setter. |
void |
setPath(java.lang.String path)
Sets my path. |
void |
setSecure(boolean secure)
Set my secure flag. |
void |
setVersion(int version)
Set the version of the HTTP cookie specification I report. |
java.lang.String |
toExternalForm()
Return a string suitable for sending in a Cookie header. |
java.lang.String |
toString()
Return a String representation of me. |
Methods inherited from class org.apache.commons.httpclient.NameValuePair |
getName, getValue, setName, setValue |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Cookie(java.lang.String domain, java.lang.String name, java.lang.String value)
name
- the cookie namevalue
- the cookie valuedomain
- the host this cookie will be sent topublic Cookie(java.lang.String domain, java.lang.String name, java.lang.String value, java.lang.String path, java.util.Date expires, boolean secure)
name
- the cookie namevalue
- the cookie valuedomain
- the host this cookie will be sent topath
- the path prefix for which this cookie will be sentexpires
- the Date
at which this cookie expires,
or null if the cookie expires at the end
of the sessionsecure
- if true this cookie will only be sent over secure connectionspublic Cookie(java.lang.String domain, java.lang.String name, java.lang.String value, java.lang.String path, int maxAge, boolean secure)
name
- the cookie namevalue
- the cookie valuedomain
- the host this cookie will be sent topath
- the path prefix for which this cookie will be sentmaxAge
- the number of seconds for which this cookie is validsecure
- if true this cookie will only be sent over secure connectionsMethod Detail |
public java.lang.String getComment()
setComment(String)
public void setComment(java.lang.String comment)
getComment()
public java.util.Date getExpiryDate()
Date
, or null
if none exists.Date
, or null.public void setExpiryDate(java.util.Date expiryDate)
Netscape's original proposal defined an Expires header that took
a date value in a fixed-length variant format in place of Max-Age:
Wdy, DD-Mon-YY HH:MM:SS GMT
Note that the Expires date format contains embedded spaces, and that
"old" cookies did not have quotes around values. Clients that
implement to this specification should be aware of "old" cookies and
Expires.
expiryDate
- the Date
after which this cookie is no longer valid.public boolean isPersistent()
public java.lang.String getDomain()
setDomain(java.lang.String)
public void setDomain(java.lang.String domain)
I should be presented only to hosts satisfying this domain name pattern. Read RFC 2109 for specific details of the syntax. Briefly, a domain name name begins with a dot (".foo.com") and means that hosts in that DNS zone ("www.foo.com", but not "a.b.foo.com") should see the cookie. By default, cookies are only returned to the host which saved them.
getDomain()
public java.lang.String getPath()
setPath(java.lang.String)
public void setPath(java.lang.String path)
I should be presented only with requests beginning with this path. See RFC 2109 for a specification of the default behaviour. Basically, URLs in the same "directory" as the one which set the cookie, and in subdirectories, can all see the cookie unless a different path is set.
public boolean getSecure()
setSecure(boolean)
public void setSecure(boolean secure)
When true the cookie should only be sent using a secure protocol (https). This should only be set when the cookie's originating server used a secure protocol to set the cookie's value.
getSecure()
public int getVersion()
public void setVersion(int version)
The current implementation only sends version 1 cookies. (See RFC 2109 for details.)
public boolean isExpired()
public boolean isExpired(java.util.Date now)
public int hashCode()
general hashCode contract
.hashCode
in class NameValuePair
public boolean equals(java.lang.Object obj)
equals
in class NameValuePair
org.apache.commons.httpclient.NameValuePair
object
- the Object
to compare topublic java.lang.String toExternalForm()
public boolean matches(java.lang.String domain, int port, java.lang.String path, boolean secure, java.util.Date now)
domain
- the host to which the request is being submittedport
- the port to which the request is being submitted (currenlty ignored)path
- the path to which the request is being submittedsecure
- true if the request is using the HTTPS protocoldate
- the time at which the request is submittedpublic boolean matches(java.lang.String domain, int port, java.lang.String path, boolean secure)
domain
- the host to which the request is being submittedport
- the port to which the request is being submitted (currenlty ignored)path
- the path to which the request is being submittedpublic static Header createCookieHeader(java.lang.String domain, java.lang.String path, Cookie[] cookies)
If no cookies match, returns null.
public static Header createCookieHeader(java.lang.String domain, java.lang.String path, boolean secure, Cookie[] cookies)
If no cookies match, returns null.
public static Header createCookieHeader(java.lang.String domain, int port, java.lang.String path, boolean secure, Cookie[] cookies)
If no cookies match, returns null.
public static Header createCookieHeader(java.lang.String domain, int port, java.lang.String path, boolean secure, java.util.Date now, Cookie[] cookies)
If no cookies match, returns null.
public java.lang.String toString()
String
representation of me.toString
in class NameValuePair
toExternalForm()
public static Cookie[] parse(java.lang.String domain, int port, java.lang.String path, Header setCookie) throws HttpException
Header
into an array of
Cookies, assuming that the cookies were recieved
on an insecure channel.domain
- the domain from which the Header
was receivedport
- the port from which the Header
was received (currently ignored)path
- the path from which the Header
was receivedsetCookie
- the Set-Cookie Header
received from the serverHeader
HttpException
- if an exception occurs during parsingpublic static Cookie[] parse(java.lang.String domain, java.lang.String path, Header setCookie) throws HttpException
Header
into an array of
Cookies, assuming that the cookies were recieved
on an insecure channel.domain
- the domain from which the Header
was receivedpath
- the path from which the Header
was receivedsetCookie
- the Set-Cookie Header
received from the serverHeader
HttpException
- if an exception occurs during parsingpublic static Cookie[] parse(java.lang.String domain, java.lang.String path, boolean secure, Header setCookie) throws HttpException
Header
into an array of
Cookies.domain
- the domain from which the Header
was receivedpath
- the path from which the Header
was receivedsecure
- true when the header was recieved over a secure channelsetCookie
- the Set-Cookie Header
received from the serverHeader
HttpException
- if an exception occurs during parsingpublic static Cookie[] parse(java.lang.String domain, int port, java.lang.String path, boolean secure, Header setCookie) throws HttpException
Header
into an array of
Cookies.
The syntax for the Set-Cookie response header is:
set-cookie = "Set-Cookie:" cookies cookies = 1#cookie cookie = NAME "=" VALUE * (";" cookie-av) NAME = attr VALUE = value cookie-av = "Comment" "=" value | "Domain" "=" value | "Max-Age" "=" value | "Path" "=" value | "Secure" | "Version" "=" 1*DIGIT
domain
- the domain from which the Header
was receivedpath
- the path from which the Header
was receivedsecure
- true when the Header
was received over HTTPSsetCookie
- the Set-Cookie Header
received from the serverHeader
HttpException
- if an exception occurs during parsing
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |