Package org.asynchttpclient.cookie
Interface CookieStore
-
- All Superinterfaces:
Counted
- All Known Implementing Classes:
ThreadSafeCookieStore
public interface CookieStore extends Counted
This interface represents an abstract store forCookieobjects.CookieManagerwill callCookieStore.addto save cookies for every incoming HTTP response, and callCookieStore.getto retrieve cookie for every outgoing HTTP request. A CookieStore is responsible for removing HttpCookie instances which have expired.- Since:
- 2.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(Uri uri, io.netty.handler.codec.http.cookie.Cookie cookie)Adds oneCookieto the store.booleanclear()Remove all cookies in this cookie store.voidevictExpired()Evicts all the cookies that expired as of the time this method is run.List<io.netty.handler.codec.http.cookie.Cookie>get(Uri uri)Retrieve cookies associated with given URI, or whose domain matches the given URI.List<io.netty.handler.codec.http.cookie.Cookie>getAll()Get all not-expired cookies in cookie store.booleanremove(Predicate<io.netty.handler.codec.http.cookie.Cookie> predicate)Remove a cookie from store.-
Methods inherited from interface org.asynchttpclient.util.Counted
count, decrementAndGet, incrementAndGet
-
-
-
-
Method Detail
-
add
void add(Uri uri, io.netty.handler.codec.http.cookie.Cookie cookie)
Adds oneCookieto the store. This is called for every incoming HTTP response. If the given cookie has already expired it will not be added.A cookie to store may or may not be associated with a URI. If it is not associated with a URI, the cookie's domain and path attribute will indicate where it comes from. If it is associated with a URI and its domain and path attribute are not specified, given URI will indicate where this cookie comes from.
If a cookie corresponding to the given URI already exists, then it is replaced with the new one.
- Parameters:
uri- theurithis cookie associated with. ifnull, this cookie will not be associated with a URIcookie- thecookieto be added
-
get
List<io.netty.handler.codec.http.cookie.Cookie> get(Uri uri)
Retrieve cookies associated with given URI, or whose domain matches the given URI. Only cookies that have not expired are returned. This is called for every outgoing HTTP request.- Parameters:
uri- theuriassociated with the cookies to be returned- Returns:
- an immutable list of Cookie, return empty list if no cookies match the given URI
-
getAll
List<io.netty.handler.codec.http.cookie.Cookie> getAll()
Get all not-expired cookies in cookie store.- Returns:
- an immutable list of http cookies; return empty list if there's no http cookie in store
-
remove
boolean remove(Predicate<io.netty.handler.codec.http.cookie.Cookie> predicate)
Remove a cookie from store.- Parameters:
predicate- that indicates what cookies to remove- Returns:
trueif this store contained the specified cookie- Throws:
NullPointerException- ifcookieisnull
-
clear
boolean clear()
Remove all cookies in this cookie store.- Returns:
- true if any cookies were purged.
-
evictExpired
void evictExpired()
Evicts all the cookies that expired as of the time this method is run.
-
-