Cookie management functions shared by all specification.
domainMatch
public boolean domainMatch(String host,
String domain) Performs domain-match as implemented in common browsers.
- domainMatch in interface CookieSpec
host - The target host.domain - The cookie domain attribute.
- true if the specified host matches the given domain.
formatCookie
public String formatCookie(Cookie cookie)
Return a string suitable for sending in a "Cookie" header
- formatCookie in interface CookieSpec
cookie - a Cookie to be formatted as string
- a string suitable for sending in a "Cookie" header.
formatCookies
public String formatCookies(Cookie[] cookies)
throws IllegalArgumentException Create a
"Cookie" header value containing all
Cookies in
cookies suitable for sending in a
"Cookie" header
- formatCookies in interface CookieSpec
cookies - an array of Cookies to be formatted
- a string suitable for sending in a Cookie header.
match
public Cookie[] match(String host,
int port,
String path,
boolean secure,
cookies[] ) Return an array of
Cookies that should be submitted with a
request with given attributes,
false otherwise.
- match in interface CookieSpec
host - the host to which the request is being submittedport - the port to which the request is being submitted (currently
ignored)path - the path to which the request is being submittedsecure - true if the request is using a secure protocol
- an array of Cookies matching the criterium
match
public 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.
- match in interface CookieSpec
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
- true if the cookie matches the criterium
parse
public Cookie[] parse(String host,
int port,
String path,
boolean secure,
String header)
throws MalformedCookieException Parses the Set-Cookie value 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
- parse in interface CookieSpec
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
- an array of Cookies parsed from the Set-Cookie value
parse
public Cookie[] parse(String host,
int port,
String path,
boolean secure,
Header header)
throws MalformedCookieException Parse the
"Set-Cookie" 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
- parse in interface CookieSpec
host - the host from which the Set-Cookie header was
receivedport - the port from which the Set-Cookie header was
receivedpath - the path from which the Set-Cookie header was
receivedsecure - true when the Set-Cookie header was
received over secure conectionheader - the Set-Cookie received from the server
- an array of Cookies parsed from the "Set-Cookie"
header
pathMatch
public boolean pathMatch(String path,
String topmostPath) Performs path-match as implemented in common browsers.
- pathMatch in interface CookieSpec
path - The target path.topmostPath - The cookie path attribute.
validate
public void validate(String host,
int port,
String path,
boolean secure,
Cookie cookie)
throws MalformedCookieException Performs most common
Cookie validation
- validate in interface CookieSpec
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.