Top Description Methods
org.apache.hc.client5.http.cookie

public Interface CookieSpec

Known Direct Implementers
org.apache.hc.client5.http.impl.cookie.AbstractCookieSpec, org.apache.hc.client5.http.impl.cookie.RFC6265CookieSpec
Imports
java.util.List, org.apache.hc.core5.http.Header

Defines the cookie management specification.

Cookie management specification must define

for a given host, port and path of origin
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 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
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