Class CookieSpecBase
- java.lang.Object
-
- org.apache.commons.httpclient.cookie.CookieSpecBase
-
- All Implemented Interfaces:
CookieSpec
- Direct Known Subclasses:
NetscapeDraftSpec,RFC2109Spec,RFC2965Spec
@Deprecated public class CookieSpecBase extends java.lang.Object implements CookieSpec
Deprecated.Jakarta Commons HttpClient 3.x is deprecated in the Jenkins project. It is not recommended to use it in any new code. Instead, use HTTP client API plugins as a dependency in your code. E.g. Apache HttpComponents Client API 4.x Plugin or Async HTTP Client Plugin.Cookie management functions shared by all specification.- Since:
- 2.0
-
-
Field Summary
-
Fields inherited from interface org.apache.commons.httpclient.cookie.CookieSpec
PATH_DELIM, PATH_DELIM_CHAR
-
-
Constructor Summary
Constructors Constructor Description CookieSpecBase()Deprecated.Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleandomainMatch(java.lang.String host, java.lang.String domain)Deprecated.Performs domain-match as implemented in common browsers.java.lang.StringformatCookie(Cookie cookie)Deprecated.Return a string suitable for sending in a "Cookie" headerHeaderformatCookieHeader(Cookie cookie)Deprecated.HeaderformatCookieHeader(Cookie[] cookies)Deprecated.java.lang.StringformatCookies(Cookie[] cookies)Deprecated.Create a "Cookie" header value containing allCookies in cookies suitable for sending in a "Cookie" headerjava.util.CollectiongetValidDateFormats()Deprecated.Returns theCollectionof date patterns used for parsing.booleanmatch(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie)Deprecated.Return true if the cookie should be submitted with a request with given attributes, false otherwise.Cookie[]match(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie[] cookies)Deprecated.Return an array ofCookies that should be submitted with a request with given attributes, false otherwise.Cookie[]parse(java.lang.String host, int port, java.lang.String path, boolean secure, java.lang.String header)Deprecated.Parses the Set-Cookie value into an array of Cookies.Cookie[]parse(java.lang.String host, int port, java.lang.String path, boolean secure, Header header)Deprecated.voidparseAttribute(NameValuePair attribute, Cookie cookie)Deprecated.Parse the cookie attribute and update the corresponsingCookieproperties.booleanpathMatch(java.lang.String path, java.lang.String topmostPath)Deprecated.Performs path-match as implemented in common browsers.voidsetValidDateFormats(java.util.Collection datepatterns)Deprecated.Sets theCollectionof date patterns used for parsing.voidvalidate(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie)Deprecated.Performs most commonCookievalidation
-
-
-
Method Detail
-
parse
public Cookie[] parse(java.lang.String host, int port, java.lang.String path, boolean secure, java.lang.String header) throws MalformedCookieException
Deprecated.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- Specified by:
parsein interfaceCookieSpec- Parameters:
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- Returns:
- an array of Cookies parsed from the Set-Cookie value
- Throws:
MalformedCookieException- if an exception occurs during parsing- See Also:
CookieSpec.validate(String, int, String, boolean, Cookie)
-
parse
public Cookie[] parse(java.lang.String host, int port, java.lang.String path, boolean secure, Header header) throws MalformedCookieException
Deprecated.Parse the "Set-Cookie"Headerinto an array ofCookies.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- Specified by:
parsein interfaceCookieSpec- Parameters:
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- Returns:
- an array of Cookies parsed from the "Set-Cookie" header
- Throws:
MalformedCookieException- if an exception occurs during parsing- See Also:
CookieSpec.validate(String, int, String, boolean, Cookie)
-
parseAttribute
public void parseAttribute(NameValuePair attribute, Cookie cookie) throws MalformedCookieException
Deprecated.Parse the cookie attribute and update the corresponsingCookieproperties.- Specified by:
parseAttributein interfaceCookieSpec- Parameters:
attribute-HeaderElementcookie attribute from the Set- Cookiecookie-Cookieto be updated- Throws:
MalformedCookieException- if an exception occurs during parsing
-
getValidDateFormats
public java.util.Collection getValidDateFormats()
Deprecated.Description copied from interface:CookieSpecReturns theCollectionof date patterns used for parsing. The String patterns are compatible with theSimpleDateFormat.- Specified by:
getValidDateFormatsin interfaceCookieSpec- Returns:
- collection of date patterns
-
setValidDateFormats
public void setValidDateFormats(java.util.Collection datepatterns)
Deprecated.Description copied from interface:CookieSpecSets theCollectionof date patterns used for parsing. The String patterns must be compatible withSimpleDateFormat.- Specified by:
setValidDateFormatsin interfaceCookieSpec- Parameters:
datepatterns- collection of date patterns
-
validate
public void validate(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie) throws MalformedCookieExceptionDeprecated.Performs most commonCookievalidation- Specified by:
validatein interfaceCookieSpec- Parameters:
host- the host from which theCookiewas receivedport- the port from which theCookiewas receivedpath- the path from which theCookiewas receivedsecure- true when theCookiewas received using a secure connectioncookie- The cookie to validate.- Throws:
MalformedCookieException- if an exception occurs during validation
-
match
public boolean match(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie)Deprecated.Return true if the cookie should be submitted with a request with given attributes, false otherwise.- Specified by:
matchin interfaceCookieSpec- Parameters:
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-Cookieto be matched- Returns:
- true if the cookie matches the criterium
-
domainMatch
public boolean domainMatch(java.lang.String host, java.lang.String domain)Deprecated.Performs domain-match as implemented in common browsers.- Specified by:
domainMatchin interfaceCookieSpec- Parameters:
host- The target host.domain- The cookie domain attribute.- Returns:
- true if the specified host matches the given domain.
-
pathMatch
public boolean pathMatch(java.lang.String path, java.lang.String topmostPath)Deprecated.Performs path-match as implemented in common browsers.- Specified by:
pathMatchin interfaceCookieSpec- Parameters:
path- The target path.topmostPath- The cookie path attribute.- Returns:
- true if the paths match
-
match
public Cookie[] match(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie[] cookies)
Deprecated.Return an array ofCookies that should be submitted with a request with given attributes, false otherwise.- Specified by:
matchin interfaceCookieSpec- Parameters:
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 matched- Returns:
- an array of Cookies matching the criterium
-
formatCookie
public java.lang.String formatCookie(Cookie cookie)
Deprecated.Return a string suitable for sending in a "Cookie" header- Specified by:
formatCookiein interfaceCookieSpec- Parameters:
cookie- aCookieto be formatted as string- Returns:
- a string suitable for sending in a "Cookie" header.
-
formatCookies
public java.lang.String formatCookies(Cookie[] cookies) throws java.lang.IllegalArgumentException
Deprecated.Create a "Cookie" header value containing allCookies in cookies suitable for sending in a "Cookie" header- Specified by:
formatCookiesin interfaceCookieSpec- Parameters:
cookies- an array ofCookies to be formatted- Returns:
- a string suitable for sending in a Cookie header.
- Throws:
java.lang.IllegalArgumentException- if an input parameter is illegal
-
formatCookieHeader
public Header formatCookieHeader(Cookie[] cookies)
Deprecated.- Specified by:
formatCookieHeaderin interfaceCookieSpec- Parameters:
cookies- an array ofCookies to be formatted as a " Cookie" header- Returns:
- a "Cookie"
Header.
-
formatCookieHeader
public Header formatCookieHeader(Cookie cookie)
Deprecated.- Specified by:
formatCookieHeaderin interfaceCookieSpec- Parameters:
cookie- Cookies to be formatted as a Cookie header- Returns:
- a Cookie header.
-
-