From 0d2ee98480b29fc82bb1d449217da31eda0713b8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 3 Aug 2019 09:55:40 +0800 Subject: [PATCH] up --- .../app/model/analyzeRule/AnalyzeUrl.kt | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 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 f6b0b83fd..bb32ec0fa 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 @@ -46,8 +46,7 @@ class AnalyzeUrl( private set var path: String? = null private set - var queryStr: String? = null - private set + private var queryStr: String? = null private val fieldMap = LinkedHashMap() private val headerMap = HashMap() private var charset: String? = null @@ -153,10 +152,6 @@ class AnalyzeUrl( body = RequestBody.create(jsonType, it) } else { analyzeFields(it) - val builder = FormBody.Builder() - for (item in fieldMap) - builder.add(item.key, item.value) - body = builder.build() } } ?: let { body = FormBody.Builder().build() @@ -206,13 +201,21 @@ class AnalyzeUrl( fun getResponseAsync(): Deferred> { return when { - method == Method.POST -> HttpHelper.getApiService( - baseUrl - ).postBodyAsync( - url, - body, - headerMap - ) + method == Method.POST -> { + if (fieldMap.isNotEmpty()) { + HttpHelper.getApiService( + baseUrl + ).postMapAsync(url, fieldMap, headerMap) + } else { + HttpHelper.getApiService( + baseUrl + ).postBodyAsync( + url, + body, + headerMap + ) + } + } fieldMap.isEmpty() -> HttpHelper.getApiService( baseUrl ).getAsync(url, headerMap)