From b2769f70d750ae1842c513a9b3ebae2d5e1800d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 15 Dec 2025 14:10:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20init=20request=20co?= =?UTF-8?q?nfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- httpclient/client.go | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/httpclient/client.go b/httpclient/client.go index 59eaf22..14ac71c 100644 --- a/httpclient/client.go +++ b/httpclient/client.go @@ -55,47 +55,8 @@ func NewHttpClient(reqConfig *define.Request, reqOption *RequestOption) (*HttpCl if len(reqConfig.SuccessHttpCodeList) == 0 { reqConfig.SuccessHttpCodeList = []int{} } - if len(reqConfig.Static) > 0 { - for loc, valMap := range reqConfig.Static { - if len(valMap) == 0 { - continue - } - l := strings.ToUpper(loc) - switch l { - case consts.RequestDataLocationHeader.String(): - if reqConfig.Header == nil { - reqConfig.Header = make(map[string]any) - } - for k, v := range valMap { - reqConfig.Header[k] = v - } - case consts.RequestDataLocationCookie.String(): - if reqConfig.Cookie == nil { - reqConfig.Cookie = make(map[string]any) - } - for k, v := range valMap { - reqConfig.Cookie[k] = v - } - case consts.RequestDataLocationBody.String(): - if reqConfig.Body == nil { - reqConfig.Body = make(map[string]any) - } - for k, v := range valMap { - reqConfig.Body[k] = v - } - case consts.RequestDataLocationQuery.String(): - if reqConfig.Query == nil { - reqConfig.Query = make(map[string]any) - } - for k, v := range valMap { - reqConfig.Query[k] = v - } - } - } - } - if reqConfig.Header == nil { - reqConfig.Header = make(map[string]any) - } + // 初始化配置 + initRequestConfig(reqConfig) if ua, exist := reqConfig.Header[consts.HeaderKeyUserAgent.String()]; !exist || nil == ua || fmt.Sprintf("%v", ua) == "" { reqConfig.Header[consts.HeaderKeyUserAgent.String()] = "resty-v3@network/httpclient" }