From 6dd5c93a222729956cda9be50d450d5ef30d0c49 Mon Sep 17 00:00:00 2001 From: Eriol Date: Tue, 29 Oct 2024 14:25:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9json=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/modules/httpclient/http_client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/modules/httpclient/http_client.go b/internal/modules/httpclient/http_client.go index afd9c2078..ade7b91ae 100644 --- a/internal/modules/httpclient/http_client.go +++ b/internal/modules/httpclient/http_client.go @@ -7,6 +7,7 @@ import ( "fmt" "io/ioutil" "net/http" + "strings" "time" ) @@ -31,7 +32,13 @@ func PostParams(url string, params string, timeout int) ResponseWrapper { if err != nil { return createRequestError(err) } - req.Header.Set("Content-type", "application/x-www-form-urlencoded") + if strings.Contains(params, "=") { + req.Header.Set("Content-type", "application/x-www-form-urlencoded") + } else if strings.Contains(params, "{") && strings.Contains(params, "}") { + req.Header.Set("Content-type", "application/json") + } else { + req.Header.Set("Content-type", "text/plain") + } return request(req, timeout) }