Support configurable HTTP user agent per exchange

This commit is contained in:
Adrian Gallagher
2018-08-07 13:05:13 +10:00
parent efc6c8d31e
commit a0de1b78a7
33 changed files with 183 additions and 9 deletions

View File

@@ -25,6 +25,7 @@ type Requester struct {
UnauthLimit *RateLimit
AuthLimit *RateLimit
Name string
UserAgent string
Cycle time.Time
m sync.Mutex
Jobs chan Job
@@ -230,6 +231,10 @@ func (r *Requester) checkRequest(method, path string, body io.Reader, headers ma
req.Header.Add(k, v)
}
if r.UserAgent != "" && req.Header.Get("User-Agent") == "" {
req.Header.Add("User-Agent", r.UserAgent)
}
return req, nil
}
@@ -245,7 +250,6 @@ func (r *Requester) DoRequest(req *http.Request, method, path string, headers ma
if r.RequiresRateLimiter() {
r.DecrementRequests(authRequest)
}
return err
}
if resp == nil {