Top Description Methods
org.apache.http.cookie

public Interface CookieSpec

Known Direct Implementers
org.apache.http.impl.cookie.AbstractCookieSpec, org.apache.http.impl.cookie.RFC6265CookieSpec, org.apache.http.impl.cookie.DefaultCookieSpec
Imports
java.util.List, org.apache.http.Header, org.apache.http.annotation.Obsolete

Defines the cookie management specification.

Cookie management specification must define

for a given host, port and path of origin

Please do not use methods marked as @Obsolete. They have been rendered obsolete by RFC 6265.

Since
4.0

Method Summary

Modifier and TypeMethod and Description
public List<Header>

Returns:

a Header for the given Cookies.
formatCookies
(List<Cookie>
the Cookies format into a Cookie header
cookies
)

Create "Cookie" headers for an array of Cookies.

public int

Returns:

version of the state management specification
getVersion
()

Returns version of the state management this cookie specification conforms to.

public Header
getVersionHeader()

Returns a request header identifying what version of the state management specification is understood.

public boolean

Returns:

true if the cookie should be submitted with a request with given attributes, false otherwise.
match
(Cookie
the Cookie to be matched
cookie
,
CookieOrigin
the target to test against
origin
)

Determines if a Cookie matches the target location.

public List<Cookie>

Returns:

an array of Cookies parsed from the header
parse
(Header
the Set-Cookie received from the server
header
,
CookieOrigin
details of the cookie origin
origin
)

Parse the "Set-Cookie" Header into an array of Cookies.

public void
validate(Cookie
the Cookie to validate
cookie
,
CookieOrigin
details of the cookie origin
origin
)

Validate the cookie according to validation rules defined by the cookie specification.

Method Detail

formatCookiesback to summary
public List<Header> formatCookies(List<Cookie> cookies)

Create "Cookie" headers for an array of Cookies.

Parameters
cookies:List<Cookie>

the Cookies format into a Cookie header

Returns:List<Header>

a Header for the given Cookies.

Exceptions
IllegalArgumentException:
if an input parameter is illegal
getVersionback to summary
public int getVersion()

Returns version of the state management this cookie specification conforms to.

Returns:int

version of the state management specification

Annotations
@Obsolete
getVersionHeaderback to summary
public Header getVersionHeader()

Returns a request header identifying what version of the state management specification is understood. May be null if the cookie specification does not support Cookie2 header.

Annotations
@Obsolete
matchback to summary
public boolean match(Cookie cookie, CookieOrigin origin)

Determines if a Cookie matches the target location.

Parameters
cookie:Cookie

the Cookie to be matched

origin:CookieOrigin

the target to test against

Returns:boolean

true if the cookie should be submitted with a request with given attributes, false otherwise.

parseback to summary
public List<Cookie> parse(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 Cookies

Parameters
header:Header

the Set-Cookie received from the server

origin:CookieOrigin

details of the cookie origin

Returns:List<Cookie>

an array of Cookies parsed from the header

Exceptions
MalformedCookieException:
if an exception occurs during parsing
See Also
validate
validateback to summary
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException

Validate the cookie according to validation rules defined by the cookie specification.

Parameters
cookie:Cookie

the Cookie to validate

origin:CookieOrigin

details of the cookie origin

Exceptions
MalformedCookieException:
if the cookie is invalid