From 8fe8d3f71691946cd62b9e1ad3f979050129816a Mon Sep 17 00:00:00 2001 From: renzhiyuan <465386466@qq.com> Date: Wed, 25 Jun 2025 10:50:57 +0800 Subject: [PATCH] first push --- request.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/request.go b/request.go index 12b0cc6..fe10663 100644 --- a/request.go +++ b/request.go @@ -69,14 +69,21 @@ func (r *Request) getData() io.Reader { urlValues.Add(key, value) } reqBody = urlValues.Encode() - r.Headers["Content-Type"] = "application/x-www-form-urlencoded" + if _, ex := r.Headers["Content-Type"]; !ex { + r.Headers["Content-Type"] = "application/x-www-form-urlencoded" + } + } else if r.Json != nil { bytesData, _ := json.Marshal(r.Json) reqBody = string(bytesData) - r.Headers["Content-Type"] = "application/json" + if _, ex := r.Headers["Content-Type"]; !ex { + r.Headers["Content-Type"] = "application/json" + } } else if r.JsonByte != nil { reqBody = string(r.JsonByte) - r.Headers["Content-Type"] = "application/json" + if _, ex := r.Headers["Content-Type"]; !ex { + r.Headers["Content-Type"] = "application/json" + } } return strings.NewReader(reqBody) }