|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.httpclient.cookie.CookieSpecBase org.apache.commons.httpclient.cookie.RFC2965Spec
public class RFC2965Spec
RFC 2965 specific cookie management functions.
Field Summary | |
---|---|
static String |
SET_COOKIE2_KEY
Cookie Response Header name for cookies processed by this spec. |
Fields inherited from class org.apache.commons.httpclient.cookie.CookieSpecBase |
---|
LOG |
Fields inherited from interface org.apache.commons.httpclient.cookie.CookieSpec |
---|
PATH_DELIM, PATH_DELIM_CHAR |
Constructor Summary | |
---|---|
RFC2965Spec()
Default constructor |
Method Summary | |
---|---|
boolean |
domainMatch(String host,
String domain)
Performs domain-match as defined by the RFC2965. |
protected CookieAttributeHandler |
findAttribHandler(String name)
Finds an attribute handler CookieAttributeHandler for the
given attribute. |
String |
formatCookie(Cookie cookie)
Return a string suitable for sending in a "Cookie" header as defined in RFC 2965 |
String |
formatCookies(Cookie[] cookies)
Create a RFC 2965 compliant "Cookie" header value containing all Cookie s suitable for
sending in a "Cookie" header |
protected CookieAttributeHandler |
getAttribHandler(String name)
Gets attribute handler CookieAttributeHandler for the
given attribute. |
protected Iterator |
getAttribHandlerIterator()
|
int |
getVersion()
|
Header |
getVersionHeader()
|
boolean |
match(String host,
int port,
String path,
boolean secure,
Cookie cookie)
Return true if the cookie should be submitted with a request with given attributes, false otherwise. |
Cookie[] |
parse(String host,
int port,
String path,
boolean secure,
Header header)
Parses the Set-Cookie2 value into an array of Cookies. |
Cookie[] |
parse(String host,
int port,
String path,
boolean secure,
String header)
Parses the Set-Cookie value into an array of Cookies. |
void |
parseAttribute(NameValuePair attribute,
Cookie cookie)
Parse RFC 2965 specific cookie attribute and update the corresponsing Cookie properties. |
protected void |
registerAttribHandler(String name,
CookieAttributeHandler handler)
|
void |
validate(String host,
int port,
String path,
boolean secure,
Cookie cookie)
Performs RFC 2965 compliant Cookie validation |
Methods inherited from class org.apache.commons.httpclient.cookie.CookieSpecBase |
---|
formatCookieHeader, formatCookieHeader, getValidDateFormats, match, pathMatch, setValidDateFormats |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String SET_COOKIE2_KEY
Constructor Detail |
---|
public RFC2965Spec()
Method Detail |
---|
protected void registerAttribHandler(String name, CookieAttributeHandler handler)
protected CookieAttributeHandler findAttribHandler(String name)
CookieAttributeHandler
for the
given attribute. Returns null if no attribute handler is
found for the specified attribute.
name
- attribute name. e.g. Domain, Path, etc.
protected CookieAttributeHandler getAttribHandler(String name)
CookieAttributeHandler
for the
given attribute.
name
- attribute name. e.g. Domain, Path, etc.
IllegalStateException
- if handler not found for the
specified attribute.protected Iterator getAttribHandlerIterator()
public Cookie[] parse(String host, int port, String path, boolean secure, Header header) throws MalformedCookieException
The syntax for the Set-Cookie2 response header is:
set-cookie = "Set-Cookie2:" cookies cookies = 1#cookie cookie = NAME "=" VALUE * (";" cookie-av) NAME = attr VALUE = value cookie-av = "Comment" "=" value | "CommentURL" "=" <"> http_URL <"> | "Discard" | "Domain" "=" value | "Max-Age" "=" value | "Path" "=" value | "Port" [ "=" <"> portlist <"> ] | "Secure" | "Version" "=" 1*DIGIT portlist = 1#portnum portnum = 1*DIGIT
parse
in interface CookieSpec
parse
in class CookieSpecBase
host
- the host from which the Set-Cookie2 value was
receivedport
- the port from which the Set-Cookie2 value was
receivedpath
- the path from which the Set-Cookie2 value was
receivedsecure
- true when the Set-Cookie2 value was
received over secure conectionheader
- the Set-Cookie2 Header received from the server
MalformedCookieException
- if an exception occurs during parsingCookieSpec.validate(String, int, String, boolean, Cookie)
public Cookie[] parse(String host, int port, String path, boolean secure, String header) throws MalformedCookieException
CookieSpecBase
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
parse
in interface CookieSpec
parse
in class CookieSpecBase
host
- the host from which the Set-Cookie value was
receivedport
- the port from which the Set-Cookie value was
receivedpath
- the path from which the Set-Cookie value was
receivedsecure
- true when the Set-Cookie value was
received over secure conectionheader
- the Set-Cookie received from the server
MalformedCookieException
- if an exception occurs during parsingparse(String, int, String, boolean, org.apache.commons.httpclient.Header)
public void parseAttribute(NameValuePair attribute, Cookie cookie) throws MalformedCookieException
Cookie
properties.
parseAttribute
in interface CookieSpec
parseAttribute
in class CookieSpecBase
attribute
- NameValuePair
cookie attribute from the
Set-Cookie2 header.cookie
- Cookie
to be updated
MalformedCookieException
- if an exception occurs during parsingpublic void validate(String host, int port, String path, boolean secure, Cookie cookie) throws MalformedCookieException
Cookie
validation
validate
in interface CookieSpec
validate
in class CookieSpecBase
host
- the host from which the Cookie
was receivedport
- the port from which the Cookie
was receivedpath
- the path from which the Cookie
was receivedsecure
- true when the Cookie
was received using a
secure connectioncookie
- The cookie to validate
MalformedCookieException
- if an exception occurs during
validationpublic boolean match(String host, int port, String path, boolean secure, Cookie cookie)
match
in interface CookieSpec
match
in class CookieSpecBase
host
- the host to which the request is being submittedport
- the port to which the request is being submitted (ignored)path
- the path to which the request is being submittedsecure
- true if the request is using a secure connectioncookie
- Cookie
to be matched
public String formatCookie(Cookie cookie)
formatCookie
in interface CookieSpec
formatCookie
in class CookieSpecBase
cookie
- a Cookie
to be formatted as string
public String formatCookies(Cookie[] cookies)
Cookie
s suitable for
sending in a "Cookie" header
formatCookies
in interface CookieSpec
formatCookies
in class CookieSpecBase
cookies
- an array of Cookie
s to be formatted
public boolean domainMatch(String host, String domain)
Host A's name domain-matches host B's if
domainMatch
in interface CookieSpec
domainMatch
in class CookieSpecBase
host
- host name where cookie is received from or being sent to.domain
- The cookie domain attribute.
public int getVersion()
getVersion
in interface CookieVersionSupport
public Header getVersionHeader()
getVersionHeader
in interface CookieVersionSupport
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |