diff options
Diffstat (limited to 'src/go/collectors/go.d.plugin/pkg/web/request.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/pkg/web/request.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/pkg/web/request.go b/src/go/collectors/go.d.plugin/pkg/web/request.go index 3db08f734f..655b3c7d0b 100644 --- a/src/go/collectors/go.d.plugin/pkg/web/request.go +++ b/src/go/collectors/go.d.plugin/pkg/web/request.go @@ -4,9 +4,13 @@ package web import ( "encoding/base64" + "fmt" "io" "net/http" "strings" + + "github.com/netdata/netdata/go/go.d.plugin/agent/executable" + "github.com/netdata/netdata/go/go.d.plugin/pkg/buildinfo" ) // Request is the configuration of the HTTP request. @@ -50,6 +54,8 @@ func (r Request) Copy() Request { return r } +var userAgent = fmt.Sprintf("Netdata %s.plugin/%s", executable.Name, buildinfo.Version) + // NewHTTPRequest returns a new *http.Requests given a Request configuration and an error if any. func NewHTTPRequest(cfg Request) (*http.Request, error) { var body io.Reader @@ -62,6 +68,8 @@ func NewHTTPRequest(cfg Request) (*http.Request, error) { return nil, err } + req.Header.Set("User-Agent", userAgent) + if cfg.Username != "" || cfg.Password != "" { req.SetBasicAuth(cfg.Username, cfg.Password) } |