Interface RequestCookies
public interface RequestCookies
A request Cookie collection.
- Since:
- 2.1.0
-
Method Summary
Modifier and TypeMethodDescriptionGets all values of the cookie with the given name, or an empty List if none exists.Gets the first cookie with the given name, or null if none exists.getFirst(String name, ValueTransformation valueTransformation) Gets the first cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.getSingleOrError(String name) Gets the cookie with the given name, null if none exists, or throw an error if multiple cookies exist with the given name.getSingleOrError(String name, ValueTransformation valueTransformation) Gets the cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.Map<String,NonEmptyList<? extends Cookie>> map()Get aMapcontaining all cookies sent with the Request, where each entry has the cookie name as the key, and a List of the the cookies with that name as the value.
-
Method Details
-
getFirst
Gets the first cookie with the given name, or null if none exists.- Parameters:
name- of the cookie- Returns:
- the first cookie with the given name, if any.
-
getFirst
Gets the first cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.- Parameters:
name- of the cookievalueTransformation- the transformation that should be applied to the cookie value- Returns:
- the first cookie with the given name, if any.
-
getSingleOrError
Gets the cookie with the given name, null if none exists, or throw an error if multiple cookies exist with the given name.- Parameters:
name- of the cookie- Returns:
- the cookie with the given name, if any.
- Throws:
MultipleCookiesException- in case more than one cookie exists
-
getSingleOrError
@Nullable @Nullable Cookie getSingleOrError(String name, ValueTransformation valueTransformation) throws MultipleCookiesException Gets the cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.- Parameters:
name- of the cookievalueTransformation- the transformation that should be applied to the cookie value- Returns:
- the cookie with the given name, if any.
- Throws:
MultipleCookiesException- in case more than one cookie exists
-
getAll
Gets all values of the cookie with the given name, or an empty List if none exists.All cookies are returned with the actual value they were sent by the client. This means that encrypted or signed cookies are not decrypted or signature-verified, respectively.
- Parameters:
name- of the cookie- Returns:
- the raw values of the cookie with the given name.
-
map
Map<String,NonEmptyList<? extends Cookie>> map()Get aMapcontaining all cookies sent with the Request, where each entry has the cookie name as the key, and a List of the the cookies with that name as the value. Notice that this method has the same restriction on encrypted and signed cookies as thegetAll(String)method.- Returns:
- a
Mapcontaining all cookies sent with the request
-