Merge pull request #1149 from tangjoin/master

Update client_request.go
This commit is contained in:
John Guo 2021-01-30 22:57:14 +08:00 committed by GitHub
commit 13248d6736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -251,6 +251,10 @@ func (c *Client) prepareRequest(method, url string, data ...interface{}) (req *h
} else { } else {
req = req.WithContext(context.Background()) req = req.WithContext(context.Background())
} }
// Client agent.
if c.agent != "" {
req.Header.Set("User-Agent", c.agent)
}
// Custom header. // Custom header.
if len(c.header) > 0 { if len(c.header) > 0 {
for k, v := range c.header { for k, v := range c.header {
@ -279,10 +283,6 @@ func (c *Client) prepareRequest(method, url string, data ...interface{}) (req *h
if len(c.authUser) > 0 { if len(c.authUser) > 0 {
req.SetBasicAuth(c.authUser, c.authPass) req.SetBasicAuth(c.authUser, c.authPass)
} }
// Client agent.
if c.agent != "" {
req.Header.Set("User-Agent", c.agent)
}
return req, nil return req, nil
} }