From 435827babd1b03791ce1aa9b3b8f1f720a51a4ae Mon Sep 17 00:00:00 2001 From: AndyBernie Date: Thu, 20 Aug 2020 17:33:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E9=93=BE=E6=8E=A5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=BB=98=E8=AE=A4ua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 c3dbd2d6b..9cbf64f8f 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,6 +4,8 @@ import android.annotation.SuppressLint import android.text.TextUtils import androidx.annotation.Keep import io.legado.app.constant.AppConst.SCRIPT_ENGINE +import io.legado.app.constant.AppConst.UA_NAME +import io.legado.app.constant.AppConst.userAgent import io.legado.app.constant.AppPattern.EXP_PATTERN import io.legado.app.constant.AppPattern.JS_PATTERN import io.legado.app.data.entities.BaseBook @@ -326,6 +328,7 @@ class AnalyzeUrl( tag: String ): ByteArray? { //资源为本站的资源,保留cookie + //图片盗链的不保留当前的cookie,可由js生成图片源站的cookie val cookie = CookieStore.getCookie(tag) NetworkUtils.getBaseUrl(url)?.let { val regex: Any @@ -336,11 +339,11 @@ class AnalyzeUrl( } if(regex.containsMatchIn(tag)) { if (cookie.isNotEmpty()) { - headerMap["Cookie"] = cookie + headerMap["Cookie"] += cookie } } } - //图片盗链的不保留当前的cookie,可由js生成图片源站的cookie + headerMap[UA_NAME] = headerMap[UA_NAME] ?:userAgent if(fieldMap.isEmpty()) { return HttpHelper.getBytes(url, mapOf(), headerMap) } else {