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)