Interface CookieSpec
-
- All Known Implementing Classes:
AbstractCookieSpec,CookieSpecBase,IgnoreSpecSpec,RFC6265CookieSpec,RFC6265CookieSpecBase,RFC6265LaxSpec,RFC6265StrictSpec
public interface CookieSpecDefines 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
- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<org.apache.hc.core5.http.Header>formatCookies(java.util.List<Cookie> cookies)Create"Cookie"headers for an array of Cookies.booleanmatch(Cookie cookie, CookieOrigin origin)Determines if a Cookie matches the target location.java.util.List<Cookie>parse(org.apache.hc.core5.http.Header header, CookieOrigin origin)Parse the"Set-Cookie"Header into an array of Cookies.voidvalidate(Cookie cookie, CookieOrigin origin)Validate the cookie according to validation rules defined by the cookie specification.
-
-
-
Method Detail
-
parse
java.util.List<Cookie> parse(org.apache.hc.core5.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
Cookies- Parameters:
header- theSet-Cookiereceived from the serverorigin- details of the cookie origin- Returns:
- an array of
Cookies parsed from the header - Throws:
MalformedCookieException- if an exception occurs during parsing- See Also:
validate(org.apache.hc.client5.http.cookie.Cookie, org.apache.hc.client5.http.cookie.CookieOrigin)
-
validate
void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException
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
boolean match(Cookie cookie, CookieOrigin origin)
Determines if a Cookie matches the target location.- Parameters:
cookie- the Cookie to be matchedorigin- the target to test against- Returns:
trueif the cookie should be submitted with a request with given attributes,falseotherwise.
-
formatCookies
java.util.List<org.apache.hc.core5.http.Header> formatCookies(java.util.List<Cookie> cookies)
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:
java.lang.IllegalArgumentException- if an input parameter is illegal
-
-