Unverified Commit 3ee50ccf authored by Matthew Fisher's avatar Matthew Fisher Committed by GitHub

Merge pull request #3174 from mattfarina/feat/user-agent

feat(http): Add a Helm user-agent string to the http getter
parents d790f7d8 275fbd43
......@@ -20,9 +20,11 @@ import (
"fmt"
"io"
"net/http"
"strings"
"k8s.io/helm/pkg/tlsutil"
"k8s.io/helm/pkg/urlutil"
"k8s.io/helm/pkg/version"
)
//httpGetter is the efault HTTP(/S) backend handler
......@@ -34,7 +36,15 @@ type httpGetter struct {
func (g *httpGetter) Get(href string) (*bytes.Buffer, error) {
buf := bytes.NewBuffer(nil)
resp, err := g.client.Get(href)
// Set a helm specific user agent so that a repo server and metrics can
// separate helm calls from other tools interacting with repos.
req, err := http.NewRequest("GET", href, nil)
if err != nil {
return buf, err
}
req.Header.Set("User-Agent", "Helm/"+strings.TrimPrefix(version.GetVersion(), "v"))
resp, err := g.client.Do(req)
if err != nil {
return buf, err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment