Package org.apache.http.cookie
Interface CookieSpec
- All Known Implementing Classes:
AbstractCookieSpec
,BestMatchSpec
,BrowserCompatSpec
,CookieSpecBase
,DefaultCookieSpec
,IgnoreSpec
,NetscapeDraftSpec
,RFC2109Spec
,RFC2965Spec
,RFC6265CookieSpec
,RFC6265LaxSpec
,RFC6265StrictSpec
public interface CookieSpec
Defines the cookie management specification.
Cookie management specification must define
- rules of parsing "Set-Cookie" header
- rules of validation of parsed cookies
- formatting of "Cookie" header
Please do not use methods marked as @Obsolete. They have been rendered obsolete by RFC 6265.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionList
<org.apache.http.Header> formatCookies
(List<Cookie> cookies) Create"Cookie"
headers for an array of Cookies.int
Returns version of the state management this cookie specification conforms to.org.apache.http.Header
Returns a request header identifying what version of the state management specification is understood.boolean
match
(Cookie cookie, CookieOrigin origin) Determines if a Cookie matches the target location.parse
(org.apache.http.Header header, CookieOrigin origin) Parse the"Set-Cookie"
Header into an array of Cookies.void
validate
(Cookie cookie, CookieOrigin origin) Validate the cookie according to validation rules defined by the cookie specification.
-
Method Details
-
getVersion
@Obsolete int getVersion()Returns version of the state management this cookie specification conforms to.- Returns:
- version of the state management specification
-
parse
List<Cookie> parse(org.apache.http.Header header, CookieOrigin origin) throws MalformedCookieException Parse the"Set-Cookie"
Header into an array of Cookies.This method will not perform the validation of the resultant
Cookie
s- Parameters:
header
- theSet-Cookie
received from the serverorigin
- details of the cookie origin- Returns:
- an array of
Cookie
s parsed from the header - Throws:
MalformedCookieException
- if an exception occurs during parsing- See Also:
-
validate
Validate the cookie according to validation rules defined by the cookie specification.- Parameters:
cookie
- the Cookie to validateorigin
- details of the cookie origin- Throws:
MalformedCookieException
- if the cookie is invalid
-
match
Determines if a Cookie matches the target location.- Parameters:
cookie
- the Cookie to be matchedorigin
- the target to test against- Returns:
true
if the cookie should be submitted with a request with given attributes,false
otherwise.
-
formatCookies
Create"Cookie"
headers for an array of Cookies.- Parameters:
cookies
- the Cookies format into a Cookie header- Returns:
- a Header for the given Cookies.
- Throws:
IllegalArgumentException
- if an input parameter is illegal
-
getVersionHeader
@Obsolete org.apache.http.Header getVersionHeader()Returns a request header identifying what version of the state management specification is understood. May benull
if the cookie specification does not supportCookie2
header.
-