Class NetscapeDraftSpec
java.lang.Object
org.apache.commons.httpclient.cookie.CookieSpecBase
org.apache.commons.httpclient.cookie.NetscapeDraftSpec
- All Implemented Interfaces:
CookieSpec
Netscape cookie draft specific cookie management functions
- Since:
- 2.0
- Author:
- B.C. Holmes, Park, Sung-Gu, Doug Sale, Rod Waldhoff, dIon Gillard, Sean C. Sullivan, John Evans, Marc A. Saegesser, Oleg Kalnichevski, Mike Bowler
-
Field Summary
Fields inherited from class CookieSpecBase
LOGFields inherited from interface CookieSpec
PATH_DELIM, PATH_DELIM_CHAR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandomainMatch(String host, String domain) Performs domain-match as described in the Netscape draft.Cookie[]Parses the Set-Cookie value into an array of Cookies.voidparseAttribute(NameValuePair attribute, Cookie cookie) Parse the cookie attribute and update the corresponsingCookieproperties as defined by the Netscape draft specificationvoidPerforms Netscape draft compliantCookievalidationMethods inherited from class CookieSpecBase
formatCookie, formatCookieHeader, formatCookieHeader, formatCookies, getValidDateFormats, match, match, parse, pathMatch, setValidDateFormats
-
Constructor Details
-
NetscapeDraftSpec
public NetscapeDraftSpec()Default constructor
-
-
Method Details
-
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.Syntax of the Set-Cookie HTTP Response Header:
This is the format a CGI script would use to add to the HTTP headers a new piece of data which is to be stored by the client for later retrieval.
Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure
Please note that Netscape draft specification does not fully conform to the HTTP header format. Netscape draft does not specify whether multiple cookies may be sent in one header. Hence, comma character may be present in unquoted cookie value or unquoted parameter value.
- Specified by:
parsein interfaceCookieSpec- Overrides:
parsein classCookieSpecBase- 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:
-
parseAttribute
Parse the cookie attribute and update the corresponsingCookieproperties as defined by the Netscape draft specification- Specified by:
parseAttributein interfaceCookieSpec- Overrides:
parseAttributein classCookieSpecBase- Parameters:
attribute-NameValuePaircookie attribute from the Set- Cookiecookie-Cookieto be updated- Throws:
MalformedCookieException- if an exception occurs during parsing
-
domainMatch
Performs domain-match as described in the Netscape draft.- Specified by:
domainMatchin interfaceCookieSpec- Overrides:
domainMatchin classCookieSpecBase- Parameters:
host- The target host.domain- The cookie domain attribute.- Returns:
- true if the specified host matches the given domain.
-
validate
public void validate(String host, int port, String path, boolean secure, Cookie cookie) throws MalformedCookieException Performs Netscape draft compliantCookievalidation- Specified by:
validatein interfaceCookieSpec- Overrides:
validatein classCookieSpecBase- 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
-