use of com.lzy.okgo.cookie.SerializableCookie in project okhttp-OkGo by jeasonlzy.
the class DBCookieStore method loadCookie.
/**
* 根据当前url获取所有需要的cookie,只返回没有过期的cookie
*/
@Override
public synchronized List<Cookie> loadCookie(HttpUrl url) {
List<Cookie> ret = new ArrayList<>();
if (!cookies.containsKey(url.host()))
return ret;
List<SerializableCookie> query = CookieManager.getInstance().query("host=?", new String[] { url.host() });
for (SerializableCookie serializableCookie : query) {
Cookie cookie = serializableCookie.getCookie();
if (isCookieExpired(cookie)) {
removeCookie(url, cookie);
} else {
ret.add(cookie);
}
}
return ret;
}
use of com.lzy.okgo.cookie.SerializableCookie in project BaseProject by feer921.
the class DBCookieStore method saveCookie.
@Override
public synchronized void saveCookie(HttpUrl url, Cookie cookie) {
if (!cookies.containsKey(url.host())) {
cookies.put(url.host(), new ConcurrentHashMap<String, Cookie>());
}
// 当前cookie是否过期
if (isCookieExpired(cookie)) {
removeCookie(url, cookie);
} else {
// 内存缓存
cookies.get(url.host()).put(getCookieToken(cookie), cookie);
// 数据库缓存
SerializableCookie serializableCookie = new SerializableCookie(url.host(), cookie);
CookieManager.getInstance().replace(serializableCookie);
}
}
use of com.lzy.okgo.cookie.SerializableCookie in project okhttp-OkGo by jeasonlzy.
the class DBCookieStore method saveCookie.
@Override
public synchronized void saveCookie(HttpUrl url, Cookie cookie) {
if (!cookies.containsKey(url.host())) {
cookies.put(url.host(), new ConcurrentHashMap<String, Cookie>());
}
// 当前cookie是否过期
if (isCookieExpired(cookie)) {
removeCookie(url, cookie);
} else {
// 内存缓存
cookies.get(url.host()).put(getCookieToken(cookie), cookie);
// 数据库缓存
SerializableCookie serializableCookie = new SerializableCookie(url.host(), cookie);
CookieManager.getInstance().replace(serializableCookie);
}
}
use of com.lzy.okgo.cookie.SerializableCookie in project BaseProject by feer921.
the class DBCookieStore method loadCookie.
/**
* 根据当前url获取所有需要的cookie,只返回没有过期的cookie
*/
@Override
public synchronized List<Cookie> loadCookie(HttpUrl url) {
List<Cookie> ret = new ArrayList<>();
if (!cookies.containsKey(url.host()))
return ret;
List<SerializableCookie> query = CookieManager.getInstance().query("host=?", new String[] { url.host() });
for (SerializableCookie serializableCookie : query) {
Cookie cookie = serializableCookie.getCookie();
if (isCookieExpired(cookie)) {
removeCookie(url, cookie);
} else {
ret.add(cookie);
}
}
return ret;
}
Aggregations