未传入User-Agent时设置默认值
This commit is contained in:
parent
60dd279663
commit
834ce55f26
@ -75,6 +75,12 @@ func NewHttpClient(reqConfig *define.Request, cacheInstance cache.ICache) (*Http
|
||||
}
|
||||
}
|
||||
}
|
||||
if reqConfig.Header == nil {
|
||||
reqConfig.Header = make(map[string]any)
|
||||
}
|
||||
if ua, exist := reqConfig.Header[consts.HeaderKeyUserAgent.String()]; !exist || nil == ua || fmt.Sprintf("%v", ua) == "" {
|
||||
reqConfig.Header[consts.HeaderKeyUserAgent.String()] = "resty-v2@network/httpclient"
|
||||
}
|
||||
restyClient, restyRequest := NewRestyClient(reqConfig)
|
||||
hc := &HttpClient{
|
||||
Client: restyClient,
|
||||
|
Loading…
x
Reference in New Issue
Block a user