mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-08 01:10:23 +00:00
优化:通过Content-Type=applicaton/json
指定请求体为json
格式 #491
This commit is contained in:
parent
3fccec54b1
commit
e3df9bada6
@ -91,6 +91,15 @@ class WebhookUtils {
|
||||
Log.i(TAG, "requestUrl:$requestUrl")
|
||||
}
|
||||
|
||||
//通过`Content-Type=applicaton/json`指定请求体为`json`格式
|
||||
var isJson = false
|
||||
for ((key, value) in setting.headers.entries) {
|
||||
if (key.equals("Content-Type", ignoreCase = true) && value.contains("application/json")) {
|
||||
isJson = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
val request = if (setting.method == "GET" && TextUtils.isEmpty(webParams)) {
|
||||
setting.webServer += (if (setting.webServer.contains("?")) "&" else "?") + "from=" + URLEncoder.encode(
|
||||
from,
|
||||
@ -128,7 +137,7 @@ class WebhookUtils {
|
||||
}
|
||||
Log.d(TAG, "method = GET, Url = $requestUrl")
|
||||
XHttp.get(requestUrl).keepJson(true)
|
||||
} else if (webParams.isNotEmpty() && webParams.startsWith("{")) {
|
||||
} else if (webParams.isNotEmpty() && (isJson || webParams.startsWith("{"))) {
|
||||
val bodyMsg = webParams.replace("[from]", from)
|
||||
.replace("[content]", escapeJson(content))
|
||||
.replace("[msg]", escapeJson(content))
|
||||
|
Loading…
Reference in New Issue
Block a user