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 {