From d034f99efbe71e6da88c96a89a4b6988ae672c49 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 1 Sep 2020 14:29:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E5=B4=A9?= =?UTF-8?q?=E6=BA=83bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 12 ++---------- 1 file changed, 2 insertions(+), 10 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 3fa15df00..16cd607d3 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 @@ -192,9 +192,8 @@ class AnalyzeUrl( option?.let { _ -> option.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST } option.headers?.let { headers -> - if (headers is Map<*, *>) { - @Suppress("unchecked_cast") - headerMap.putAll(headers as Map) + (headers as? Map<*, *>)?.forEach { key, value -> + headerMap[key.toString()] = value.toString() } if (headers is String) { GSON.fromJsonObject>(headers) @@ -242,7 +241,6 @@ class AnalyzeUrl( /** * 解析QueryMap */ - @Throws(Exception::class) private fun analyzeFields(fieldsTxt: String) { queryStr = fieldsTxt val queryS = fieldsTxt.splitNotBlank("&") @@ -266,7 +264,6 @@ class AnalyzeUrl( /** * 执行JS */ - @Throws(Exception::class) private fun evalJS( jsStr: String, result: Any?, @@ -288,7 +285,6 @@ class AnalyzeUrl( return SCRIPT_ENGINE.eval(jsStr, bindings) } - @Throws(Exception::class) fun getResponse(tag: String): Call { val cookie = CookieStore.getCookie(tag) if (cookie.isNotEmpty()) { @@ -315,7 +311,6 @@ class AnalyzeUrl( } } - @Throws(Exception::class) suspend fun getResponseAwait( tag: String, jsStr: String? = null, @@ -388,7 +383,6 @@ class AnalyzeUrl( return Res(NetworkUtils.getUrl(res), res.body()) } - @Throws(Exception::class) fun getImageBytes(tag: String): ByteArray? { val cookie = CookieStore.getCookie(tag) if (cookie.isNotEmpty()) { @@ -401,7 +395,6 @@ class AnalyzeUrl( } } - @Throws(Exception::class) suspend fun getResponseBytes(tag: String? = null): ByteArray? { if (tag != null) { val cookie = CookieStore.getCookie(tag) @@ -431,7 +424,6 @@ class AnalyzeUrl( return response.body() } - @Throws(Exception::class) fun getGlideUrl(): Any? { var glideUrl: Any = urlHasQuery if (headerMap.isNotEmpty()) {