From 26663981f77ea9804bf4f518a54d60cab895a5f4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 13 Jul 2020 15:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 1 + app/src/main/java/io/legado/app/help/http/HttpHelper.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 45fe53a15..cb11eee2f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -171,6 +171,7 @@ dependencies { //网络 //noinspection GradleDependency implementation 'com.squareup.retrofit2:retrofit:2.7.2' + implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1' //Glide implementation 'com.github.bumptech.glide:glide:4.11.0' diff --git a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt index e88702b32..84c4188cd 100644 --- a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt @@ -1,5 +1,9 @@ package io.legado.app.help.http +import com.franmontiel.persistentcookiejar.PersistentCookieJar +import com.franmontiel.persistentcookiejar.cache.SetCookieCache +import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor +import io.legado.app.App import io.legado.app.constant.AppConst import io.legado.app.help.http.api.HttpGetApi import io.legado.app.utils.NetworkUtils @@ -17,6 +21,9 @@ object HttpHelper { val client: OkHttpClient by lazy { + val cookieJar = + PersistentCookieJar(SetCookieCache(), SharedPrefsCookiePersistor(App.INSTANCE)) + val specs = arrayListOf( ConnectionSpec.MODERN_TLS, ConnectionSpec.COMPATIBLE_TLS, @@ -35,6 +42,7 @@ object HttpHelper { .followSslRedirects(true) .protocols(listOf(Protocol.HTTP_1_1)) .addInterceptor(getHeaderInterceptor()) + .cookieJar(cookieJar) builder.build() }