|
|
|
@ -15,8 +15,9 @@ object CookieStore : CookieManager { |
|
|
|
|
*保存cookie到数据库,会自动识别url的二级域名 |
|
|
|
|
*/ |
|
|
|
|
override fun setCookie(url: String, cookie: String?) { |
|
|
|
|
CacheManager.putMemory(url, cookie ?: "") |
|
|
|
|
val cookieBean = Cookie(NetworkUtils.getSubDomain(url), cookie ?: "") |
|
|
|
|
val domain = NetworkUtils.getSubDomain(url) |
|
|
|
|
CacheManager.putMemory("${domain}_cookie", cookie ?: "") |
|
|
|
|
val cookieBean = Cookie(domain, cookie ?: "") |
|
|
|
|
appDb.cookieDao.insert(cookieBean) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -39,8 +40,9 @@ object CookieStore : CookieManager { |
|
|
|
|
*获取url所属的二级域名的cookie |
|
|
|
|
*/ |
|
|
|
|
override fun getCookie(url: String): String { |
|
|
|
|
CacheManager.getFromMemory(url)?.let { return it } |
|
|
|
|
val cookieBean = appDb.cookieDao.get(NetworkUtils.getSubDomain(url)) |
|
|
|
|
val domain = NetworkUtils.getSubDomain(url) |
|
|
|
|
CacheManager.getFromMemory("${domain}_cookie")?.let { return it } |
|
|
|
|
val cookieBean = appDb.cookieDao.get(domain) |
|
|
|
|
val cookie = cookieBean?.cookie ?: "" |
|
|
|
|
CacheManager.putMemory(url, cookie ?: "") |
|
|
|
|
return cookie |
|
|
|
@ -53,7 +55,9 @@ object CookieStore : CookieManager { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun removeCookie(url: String) { |
|
|
|
|
appDb.cookieDao.delete(NetworkUtils.getSubDomain(url)) |
|
|
|
|
val domain = NetworkUtils.getSubDomain(url) |
|
|
|
|
CacheManager.deleteMemory("${domain}_cookie") |
|
|
|
|
appDb.cookieDao.delete(domain) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun cookieToMap(cookie: String): MutableMap<String, String> { |
|
|
|
|