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 class
ThreadSafeCookieStore.DomainUtils
-
Constructor Summary
Constructors Constructor Description ThreadSafeCookieStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Uri uri, io.netty.handler.codec.http.cookie.Cookie cookie)
Adds oneCookie
to the store.boolean
clear()
Remove all cookies in this cookie store.int
count()
Return the current counterint
decrementAndGet()
Decrement counter and return the decremented valuevoid
evictExpired()
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()
int
incrementAndGet()
Increment counter and return the incremented valueboolean
remove(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:CookieStore
Adds oneCookie
to 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 an URI. If it is not associated with an URI, the cookie's domain and path attribute will indicate where it comes from. If it is associated with an 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:
add
in interfaceCookieStore
- Parameters:
uri
- theuri
this cookie associated with. ifnull
, this cookie will not be associated with an URIcookie
- thecookie
to be added
-
get
public List<io.netty.handler.codec.http.cookie.Cookie> get(Uri uri)
Description copied from interface:CookieStore
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.- Specified by:
get
in interfaceCookieStore
- Parameters:
uri
- theuri
associated 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:CookieStore
Get all not-expired cookies in cookie store.- Specified by:
getAll
in 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:CookieStore
Remove a cookie from store.- Specified by:
remove
in interfaceCookieStore
- Parameters:
predicate
- that indicates what cookies to remove- Returns:
true
if this store contained the specified cookie
-
clear
public boolean clear()
Description copied from interface:CookieStore
Remove all cookies in this cookie store.- Specified by:
clear
in interfaceCookieStore
- Returns:
- true if any cookies were purged.
-
evictExpired
public void evictExpired()
Description copied from interface:CookieStore
Evicts all the cookies that expired as of the time this method is run.- Specified by:
evictExpired
in interfaceCookieStore
-
incrementAndGet
public int incrementAndGet()
Description copied from interface:Counted
Increment counter and return the incremented value- Specified by:
incrementAndGet
in interfaceCounted
-
decrementAndGet
public int decrementAndGet()
Description copied from interface:Counted
Decrement counter and return the decremented value- Specified by:
decrementAndGet
in interfaceCounted
-
count
public int count()
Description copied from interface:Counted
Return the current counter
-
-