public class CookieSpecBase extends Object implements CookieSpec
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
LOG
Log object
|
PATH_DELIM, PATH_DELIM_CHAR
Constructor and Description |
---|
CookieSpecBase()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
domainMatch(String host,
String domain)
Performs domain-match as implemented in common browsers.
|
String |
formatCookie(Cookie cookie)
Return a string suitable for sending in a "Cookie" header
|
org.apache.commons.httpclient.Header |
formatCookieHeader(Cookie cookie)
Create a "Cookie"
Header containing the Cookie . |
org.apache.commons.httpclient.Header |
formatCookieHeader(Cookie[] cookies)
Create a "Cookie"
Header containing all Cookie s
in cookies. |
String |
formatCookies(Cookie[] cookies)
Create a "Cookie" header value containing all
Cookie s in
cookies suitable for sending in a "Cookie" header |
Collection<String> |
getValidDateFormats()
Returns the
Collection of date patterns used for parsing. |
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[] |
match(String host,
int port,
String path,
boolean secure,
Cookie[] cookies)
Deprecated.
use match(String, int, String, boolean, SortedMap)
// END IA/HERITRIX CHANGES
|
Cookie[] |
match(String host,
int port,
String path,
boolean secure,
SortedMap<String,Cookie> cookies)
Return an array of
Cookie s that should be submitted with a
request with given attributes, false otherwise. |
Cookie[] |
parse(String host,
int port,
String path,
boolean secure,
org.apache.commons.httpclient.Header header)
Parse the "Set-Cookie"
Header into an array of Cookie s. |
Cookie[] |
parse(String host,
int port,
String path,
boolean secure,
String header)
Parses the Set-Cookie value into an array of Cookies.
|
void |
parseAttribute(org.apache.commons.httpclient.NameValuePair attribute,
Cookie cookie)
Parse the cookie attribute and update the corresponsing
Cookie
properties. |
boolean |
pathMatch(String path,
String topmostPath)
Performs path-match as implemented in common browsers.
|
void |
setValidDateFormats(Collection<String> datepatterns)
Sets the
Collection of date patterns used for parsing. |
void |
validate(String host,
int port,
String path,
boolean secure,
Cookie cookie)
Performs most common
Cookie validation |
public Cookie[] parse(String host, int port, String path, boolean secure, String header) throws org.apache.commons.httpclient.cookie.MalformedCookieException
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 serverMalformedCookieException
- if an exception occurs during parsingCookieSpec.validate(String, int, String, boolean, Cookie)
public Cookie[] parse(String host, int port, String path, boolean secure, org.apache.commons.httpclient.Header header) throws org.apache.commons.httpclient.cookie.MalformedCookieException
Header
into an array of Cookie
s.
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 serverMalformedCookieException
- if an exception occurs during parsingCookieSpec.validate(String, int, String, boolean, Cookie)
public void parseAttribute(org.apache.commons.httpclient.NameValuePair attribute, Cookie cookie) throws org.apache.commons.httpclient.cookie.MalformedCookieException
Cookie
properties.parseAttribute
in interface CookieSpec
attribute
- HeaderElement
cookie attribute from the
Set- Cookiecookie
- Cookie
to be updatedMalformedCookieException
- if an exception occurs during parsingpublic Collection<String> getValidDateFormats()
CookieSpec
Collection
of date patterns used for parsing. The String patterns are compatible
with the SimpleDateFormat
.getValidDateFormats
in interface CookieSpec
public void setValidDateFormats(Collection<String> datepatterns)
CookieSpec
Collection
of date patterns used for parsing. The String patterns must be
compatible with SimpleDateFormat
.setValidDateFormats
in interface CookieSpec
datepatterns
- collection of date patternspublic void validate(String host, int port, String path, boolean secure, Cookie cookie) throws org.apache.commons.httpclient.cookie.MalformedCookieException
Cookie
validationvalidate
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.MalformedCookieException
- if an exception occurs during
validationpublic boolean match(String host, int port, String path, boolean secure, Cookie cookie)
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 matchedpublic boolean domainMatch(String host, String domain)
domainMatch
in interface CookieSpec
host
- The target host.domain
- The cookie domain attribute.public boolean pathMatch(String path, String topmostPath)
pathMatch
in interface CookieSpec
path
- The target path.topmostPath
- The cookie path attribute.public Cookie[] match(String host, int port, String path, boolean secure, Cookie[] cookies)
Cookie
s 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 protocolcookies
- an array of Cookies to be matchedpublic Cookie[] match(String host, int port, String path, boolean secure, SortedMap<String,Cookie> cookies)
Cookie
s that should be submitted with a
request with given attributes, false otherwise.
If the SortedMap comes from an HttpState and is not itself
thread-safe, it may be necessary to synchronize on the HttpState
instance to protect against concurrent modification.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 protocolcookies
- SortedMap of Cookies to be matchedpublic String formatCookie(Cookie cookie)
formatCookie
in interface CookieSpec
cookie
- a Cookie
to be formatted as stringpublic String formatCookies(Cookie[] cookies) throws IllegalArgumentException
Cookie
s in
cookies suitable for sending in a "Cookie" headerformatCookies
in interface CookieSpec
cookies
- an array of Cookie
s to be formattedIllegalArgumentException
- if an input parameter is illegalpublic org.apache.commons.httpclient.Header formatCookieHeader(Cookie[] cookies)
Header
containing all Cookie
s
in cookies.formatCookieHeader
in interface CookieSpec
cookies
- an array of Cookie
s to be formatted as a "
Cookie" headerHeader
.public org.apache.commons.httpclient.Header formatCookieHeader(Cookie cookie)
Header
containing the Cookie
.formatCookieHeader
in interface CookieSpec
cookie
- Cookies to be formatted as a Cookie
headerCopyright © 2003-2014 Internet Archive. All Rights Reserved.