pull/32/head
kunfei 5 years ago
parent 077870db57
commit 0d2ee98480
  1. 29
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -46,8 +46,7 @@ class AnalyzeUrl(
private set private set
var path: String? = null var path: String? = null
private set private set
var queryStr: String? = null private var queryStr: String? = null
private set
private val fieldMap = LinkedHashMap<String, String>() private val fieldMap = LinkedHashMap<String, String>()
private val headerMap = HashMap<String, String>() private val headerMap = HashMap<String, String>()
private var charset: String? = null private var charset: String? = null
@ -153,10 +152,6 @@ class AnalyzeUrl(
body = RequestBody.create(jsonType, it) body = RequestBody.create(jsonType, it)
} else { } else {
analyzeFields(it) analyzeFields(it)
val builder = FormBody.Builder()
for (item in fieldMap)
builder.add(item.key, item.value)
body = builder.build()
} }
} ?: let { } ?: let {
body = FormBody.Builder().build() body = FormBody.Builder().build()
@ -206,13 +201,21 @@ class AnalyzeUrl(
fun getResponseAsync(): Deferred<Response<String>> { fun getResponseAsync(): Deferred<Response<String>> {
return when { return when {
method == Method.POST -> HttpHelper.getApiService<IHttpPostApi>( method == Method.POST -> {
baseUrl if (fieldMap.isNotEmpty()) {
).postBodyAsync( HttpHelper.getApiService<IHttpPostApi>(
url, baseUrl
body, ).postMapAsync(url, fieldMap, headerMap)
headerMap } else {
) HttpHelper.getApiService<IHttpPostApi>(
baseUrl
).postBodyAsync(
url,
body,
headerMap
)
}
}
fieldMap.isEmpty() -> HttpHelper.getApiService<IHttpGetApi>( fieldMap.isEmpty() -> HttpHelper.getApiService<IHttpGetApi>(
baseUrl baseUrl
).getAsync(url, headerMap) ).getAsync(url, headerMap)

Loading…
Cancel
Save