Package org.asynchttpclient.cookie
Class ThreadSafeCookieStore
- java.lang.Object
-
- org.asynchttpclient.cookie.ThreadSafeCookieStore
-
- All Implemented Interfaces:
CookieStore,Counted
public final class ThreadSafeCookieStore extends Object implements CookieStore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classThreadSafeCookieStore.DomainUtils
-
Constructor Summary
Constructors Constructor Description ThreadSafeCookieStore()
-
Method Summary
All Methods Instance Methods Concrete 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.intcount()Return the current counterintdecrementAndGet()Decrement counter and return the decremented valuevoidevictExpired()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.Map<String,Map<org.asynchttpclient.cookie.ThreadSafeCookieStore.CookieKey,org.asynchttpclient.cookie.ThreadSafeCookieStore.StoredCookie>>getUnderlying()intincrementAndGet()Increment counter and return the incremented valuebooleanremove(Predicate<io.netty.handler.codec.http.cookie.Cookie> predicate)Remove a cookie from store.
-
-
-
Method Detail
-
add
public void add(Uri uri, io.netty.handler.codec.http.cookie.Cookie cookie)
Description copied from interface:CookieStoreAdds 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.
- Specified by:
addin interfaceCookieStore- Parameters:
uri- theurithis cookie associated with. ifnull, this cookie will not be associated with a URIcookie- thecookieto be added
-
get
public List<io.netty.handler.codec.http.cookie.Cookie> get(Uri uri)
Description copied from interface:CookieStoreRetrieve 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.- Specified by:
getin interfaceCookieStore- 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
public List<io.netty.handler.codec.http.cookie.Cookie> getAll()
Description copied from interface:CookieStoreGet all not-expired cookies in cookie store.- Specified by:
getAllin interfaceCookieStore- Returns:
- an immutable list of http cookies; return empty list if there's no http cookie in store
-
remove
public boolean remove(Predicate<io.netty.handler.codec.http.cookie.Cookie> predicate)
Description copied from interface:CookieStoreRemove a cookie from store.- Specified by:
removein interfaceCookieStore- Parameters:
predicate- that indicates what cookies to remove- Returns:
trueif this store contained the specified cookie
-
clear
public boolean clear()
Description copied from interface:CookieStoreRemove all cookies in this cookie store.- Specified by:
clearin interfaceCookieStore- Returns:
- true if any cookies were purged.
-
evictExpired
public void evictExpired()
Description copied from interface:CookieStoreEvicts all the cookies that expired as of the time this method is run.- Specified by:
evictExpiredin interfaceCookieStore
-
incrementAndGet
public int incrementAndGet()
Description copied from interface:CountedIncrement counter and return the incremented value- Specified by:
incrementAndGetin interfaceCounted
-
decrementAndGet
public int decrementAndGet()
Description copied from interface:CountedDecrement counter and return the decremented value- Specified by:
decrementAndGetin interfaceCounted
-
count
public int count()
Description copied from interface:CountedReturn the current counter
-
-