File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
app/src/main/java/io/legado/app/help/http Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 1
1
package io.legado.app.help.http
2
2
3
+ import io.legado.app.constant.AppLog
3
4
import io.legado.app.data.appDb
4
5
import io.legado.app.help.CacheManager
5
6
import io.legado.app.utils.NetworkUtils
@@ -49,15 +50,24 @@ object CookieManager {
49
50
* 加载Cookies到请求中
50
51
*/
51
52
fun loadRequest (request : Request ): Request {
52
- val domain = NetworkUtils .getSubDomain(request.url.toString())
53
+ val url = request.url.toString()
54
+ val domain = NetworkUtils .getSubDomain(url)
53
55
54
56
val cookie = CookieStore .getCookie(domain)
55
57
val requestCookie = request.header(" Cookie" )
56
58
57
- mergeCookies(cookie, requestCookie)?.let {
58
- return request.newBuilder()
59
- .header(" Cookie" , it)
60
- .build()
59
+ mergeCookies(cookie, requestCookie)?.let { cookie ->
60
+ kotlin.runCatching {
61
+ return request.newBuilder()
62
+ .header(" Cookie" , cookie)
63
+ .build()
64
+ }.onFailure {
65
+ CookieStore .removeCookie(url)
66
+ AppLog .put(
67
+ " 设置cookie出错,已清除cookie $domain cookie:$cookie \n ${it.localizedMessage} " ,
68
+ it
69
+ )
70
+ }
61
71
}
62
72
return request
63
73
}
You can’t perform that action at this time.
0 commit comments