From bed1791dbf6d6288199556b1f590db84188de360 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 4 Oct 2020 21:31: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 --- .../legado/app/model/analyzeRule/AnalyzeUrl.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 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 f653c8032..3ff224e6f 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 @@ -191,7 +191,9 @@ class AnalyzeUrl( if (urlArray.size > 1) { val option = GSON.fromJsonObject(urlArray[1]) option?.let { _ -> - option.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST } + option.method?.let { + if (it.equals("POST", true)) method = RequestMethod.POST + } option.type?.let { type = it } option.headers?.let { headers -> if (headers is Map<*, *>) { @@ -202,13 +204,13 @@ class AnalyzeUrl( GSON.fromJsonObject>(headers) ?.let { headerMap.putAll(it) } } + headerMap[UA_NAME] ?: let { + headerMap[UA_NAME] = userAgent + } } - headerMap[UA_NAME] = headerMap[UA_NAME] ?: userAgent - charset = option.charset - body = if (option.body is String) { - option.body - } else { - GSON.toJson(option.body) + option.charset?.let { charset = it } + option.body?.let { + body = if (it is String) it else GSON.toJson(it) } option.webView?.let { if (it.toString().isNotEmpty()) {