Update client_request.go
@@ -251,6 +251,10 @@ func (c *Client) prepareRequest(method, url string, data ...interface{}) (req *h
} else {
req = req.WithContext(context.Background())
}
+ // Client agent.
+ if c.agent != "" {
+ req.Header.Set("User-Agent", c.agent)
+ }
// Custom header.
if len(c.header) > 0 {
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 {
req.SetBasicAuth(c.authUser, c.authPass)
}
- // Client agent.
- if c.agent != "" {
- req.Header.Set("User-Agent", c.agent)
- }
return req, nil
}
