public class CookieSpecBase extends Object implements CookieSpec
| 限定符和类型 | 字段和说明 |
|---|---|
protected static org.apache.commons.logging.Log |
LOG
Log object
|
PATH_DELIM, PATH_DELIM_CHAR| 构造器和说明 |
|---|
CookieSpecBase()
Default constructor
|
| 限定符和类型 | 方法和说明 |
|---|---|
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
|
Header |
formatCookieHeader(Cookie cookie)
|
Header |
formatCookieHeader(Cookie[] cookies)
|
String |
formatCookies(Cookie[] cookies)
Create a "Cookie" header value containing all
Cookies in
cookies suitable for sending in a "Cookie" header |
Collection |
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)
Return an array of
Cookies that should be submitted with a
request with given attributes, false otherwise. |
Cookie[] |
parse(String host,
int port,
String path,
boolean secure,
Header header)
|
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 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 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 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 在接口中 CookieSpechost - 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, Header header) throws MalformedCookieException
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 在接口中 CookieSpechost - 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(NameValuePair attribute, Cookie cookie) throws MalformedCookieException
Cookie
properties.parseAttribute 在接口中 CookieSpecattribute - HeaderElement cookie attribute from the
Set- Cookiecookie - Cookie to be updatedMalformedCookieException - if an exception occurs during parsingpublic Collection getValidDateFormats()
CookieSpecCollection of date patterns used for parsing. The String patterns are compatible
with the SimpleDateFormat.getValidDateFormats 在接口中 CookieSpecpublic void setValidDateFormats(Collection datepatterns)
CookieSpecCollection of date patterns used for parsing. The String patterns must be
compatible with SimpleDateFormat.setValidDateFormats 在接口中 CookieSpecdatepatterns - collection of date patternspublic void validate(String host, int port, String path, boolean secure, Cookie cookie) throws MalformedCookieException
Cookie validationvalidate 在接口中 CookieSpechost - 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 在接口中 CookieSpechost - 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 在接口中 CookieSpechost - The target host.domain - The cookie domain attribute.public boolean pathMatch(String path, String topmostPath)
pathMatch 在接口中 CookieSpecpath - The target path.topmostPath - The cookie path attribute.public Cookie[] match(String host, int port, String path, boolean secure, Cookie[] cookies)
Cookies that should be submitted with a
request with given attributes, false otherwise.match 在接口中 CookieSpechost - 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 String formatCookie(Cookie cookie)
formatCookie 在接口中 CookieSpeccookie - a Cookie to be formatted as stringpublic String formatCookies(Cookie[] cookies) throws IllegalArgumentException
Cookies in
cookies suitable for sending in a "Cookie" headerformatCookies 在接口中 CookieSpeccookies - an array of Cookies to be formattedIllegalArgumentException - if an input parameter is illegalpublic Header formatCookieHeader(Cookie[] cookies)
formatCookieHeader 在接口中 CookieSpeccookies - an array of Cookies to be formatted as a "
Cookie" headerHeader.public Header formatCookieHeader(Cookie cookie)
formatCookieHeader 在接口中 CookieSpeccookie - Cookies to be formatted as a Cookie
headerCopyright © 2017. All rights reserved.