From 874dc44dc1afafda05488f2e6f64fdf40afa6ef8 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 19 Dec 2021 10:30:47 +0800 Subject: [PATCH] =?UTF-8?q?post=E5=8F=AF=E4=BB=A5=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E8=AF=86=E5=88=ABcontentType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 589b511d8..5d4890829 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 @@ -435,8 +435,13 @@ class AnalyzeUrl( when (method) { RequestMethod.POST -> { url(urlNoQuery) + val contentType = headerMap["Content-Type"] + val body = body if (fieldMap.isNotEmpty() || body.isNullOrBlank()) { postForm(fieldMap, true) + } else if (!contentType.isNullOrBlank()) { + val requestBody = body.toRequestBody(contentType.toMediaType()) + post(requestBody) } else { postJson(body) } @@ -466,8 +471,13 @@ class AnalyzeUrl( when (method) { RequestMethod.POST -> { url(urlNoQuery) + val contentType = headerMap["Content-Type"] + val body = body if (fieldMap.isNotEmpty() || body.isNullOrBlank()) { postForm(fieldMap, true) + } else if (!contentType.isNullOrBlank()) { + val requestBody = body.toRequestBody(contentType.toMediaType()) + post(requestBody) } else { postJson(body) }