From 1d474c716ca6e1805554f37a9b48779d8af44e1c Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 8 May 2022 07:28:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=88=9B=E5=BB=BA=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=A9=BA=E7=9A=84GlideHeaders,=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84=E7=A1=AE=E5=AE=9E=E8=87=AA=E5=B8=A6ua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/glide/GlideHeaders.kt | 11 +++++++++++ .../io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 10 ++-------- 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/io/legado/app/help/glide/GlideHeaders.kt diff --git a/app/src/main/java/io/legado/app/help/glide/GlideHeaders.kt b/app/src/main/java/io/legado/app/help/glide/GlideHeaders.kt new file mode 100644 index 000000000..a488c61f7 --- /dev/null +++ b/app/src/main/java/io/legado/app/help/glide/GlideHeaders.kt @@ -0,0 +1,11 @@ +package io.legado.app.help.glide + +import com.bumptech.glide.load.model.Headers + +class GlideHeaders(private val headers: MutableMap) : Headers { + + override fun getHeaders(): MutableMap { + return headers + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 65b36ee37..2802921d5 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.util.Base64 import androidx.annotation.Keep import com.bumptech.glide.load.model.GlideUrl -import com.bumptech.glide.load.model.LazyHeaders import com.script.SimpleBindings import io.legado.app.constant.AppConst.SCRIPT_ENGINE import io.legado.app.constant.AppConst.UA_NAME @@ -17,6 +16,7 @@ import io.legado.app.exception.ConcurrentException import io.legado.app.help.CacheManager import io.legado.app.help.JsExtensions import io.legado.app.help.config.AppConfig +import io.legado.app.help.glide.GlideHeaders import io.legado.app.help.http.* import io.legado.app.utils.* import kotlinx.coroutines.runBlocking @@ -540,13 +540,7 @@ class AnalyzeUrl( */ fun getGlideUrl(): GlideUrl { setCookie(source?.getKey()) - val headers = LazyHeaders.Builder() - //删除glide默认ua - headers.setHeader(UA_NAME, null as String?) - headerMap.forEach { (key, value) -> - headers.addHeader(key, value) - } - return GlideUrl(url, headers.build()) + return GlideUrl(url, GlideHeaders(headerMap)) } fun getUserAgent(): String {