From 01f7b7acec282c452a49bd098e2dcb0cb63c0c82 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 5 Mar 2024 16:10:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=B7=E6=B1=82=E5=B7=A5=E5=85=B7PUT?= =?UTF-8?q?=E3=80=81POST=E7=9A=84=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=AE=BE=E4=B8=BA3s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/utils/fetch/fetch.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/framework/utils/fetch/fetch.go b/src/framework/utils/fetch/fetch.go index ee84324d..008b557a 100644 --- a/src/framework/utils/fetch/fetch.go +++ b/src/framework/utils/fetch/fetch.go @@ -86,7 +86,9 @@ func Post(url string, data url.Values, headers map[string]string) ([]byte, error // PostJSON 发送 POST 请求,并将请求体序列化为 JSON 格式 func PostJSON(url string, data any, headers map[string]string) ([]byte, error) { - client := &http.Client{} + client := &http.Client{ + Timeout: 3 * time.Second, // 超时时间 + } jsonData, err := json.Marshal(data) if err != nil { @@ -177,7 +179,9 @@ func PostUploadFile(url string, params map[string]string, file *os.File) ([]byte // PutJSON 发送 PUT 请求,并将请求体序列化为 JSON 格式 func PutJSON(url string, data any, headers map[string]string) ([]byte, error) { - client := &http.Client{} + client := &http.Client{ + Timeout: 3 * time.Second, // 超时时间 + } jsonData, err := json.Marshal(data) if err != nil {