post可以正确识别contentType

pull/1486/head
gedoor 3 years ago
parent 16007e0899
commit 874dc44dc1
  1. 10
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt

@ -435,8 +435,13 @@ class AnalyzeUrl(
when (method) { when (method) {
RequestMethod.POST -> { RequestMethod.POST -> {
url(urlNoQuery) url(urlNoQuery)
val contentType = headerMap["Content-Type"]
val body = body
if (fieldMap.isNotEmpty() || body.isNullOrBlank()) { if (fieldMap.isNotEmpty() || body.isNullOrBlank()) {
postForm(fieldMap, true) postForm(fieldMap, true)
} else if (!contentType.isNullOrBlank()) {
val requestBody = body.toRequestBody(contentType.toMediaType())
post(requestBody)
} else { } else {
postJson(body) postJson(body)
} }
@ -466,8 +471,13 @@ class AnalyzeUrl(
when (method) { when (method) {
RequestMethod.POST -> { RequestMethod.POST -> {
url(urlNoQuery) url(urlNoQuery)
val contentType = headerMap["Content-Type"]
val body = body
if (fieldMap.isNotEmpty() || body.isNullOrBlank()) { if (fieldMap.isNotEmpty() || body.isNullOrBlank()) {
postForm(fieldMap, true) postForm(fieldMap, true)
} else if (!contentType.isNullOrBlank()) {
val requestBody = body.toRequestBody(contentType.toMediaType())
post(requestBody)
} else { } else {
postJson(body) postJson(body)
} }

Loading…
Cancel
Save