From a5f0a3ff8026e05cbdd11c391c0e25122497c736 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Thu, 15 Nov 2018 14:02:34 -0800 Subject: [PATCH] Add version to xenolf-acme in User-Agent. (#719) Also, remove "Go-http-client/1.1". In practice this added detail doesn't wind up being useful in diagnosing problems, particularly since it can be deduced from the xenolf-acme version. * add UA comments. --- acme/http.go | 14 ++++++++------ acme/http_test.go | 2 -- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/acme/http.go b/acme/http.go index 8a8bf6db..8343b369 100644 --- a/acme/http.go +++ b/acme/http.go @@ -42,12 +42,14 @@ var ( ) const ( - // defaultGoUserAgent is the Go HTTP package user agent string. Too - // bad it isn't exported. If it changes, we should update it here, too. - defaultGoUserAgent = "Go-http-client/1.1" - // ourUserAgent is the User-Agent of this underlying library package. - ourUserAgent = "xenolf-acme" + // NOTE: Update this with each tagged release. + ourUserAgent = "xenolf-acme/1.2.1" + + // ourUserAgentComment is part of the UA comment linked to the version status of this underlying library package. + // values: detach|release + // NOTE: Update this with each tagged release. + ourUserAgentComment = "detach" // caCertificatesEnvVar is the environment variable name that can be used to // specify the path to PEM encoded CA Certificates that can be used to @@ -205,6 +207,6 @@ func post(j *jws, uri string, reqBody []byte, respBody interface{}) (*http.Respo // userAgent builds and returns the User-Agent string to use in requests. func userAgent() string { - ua := fmt.Sprintf("%s %s (%s; %s) %s", UserAgent, ourUserAgent, runtime.GOOS, runtime.GOARCH, defaultGoUserAgent) + ua := fmt.Sprintf("%s %s (%s; %s; %s)", UserAgent, ourUserAgent, ourUserAgentComment, runtime.GOOS, runtime.GOARCH) return strings.TrimSpace(ua) } diff --git a/acme/http_test.go b/acme/http_test.go index 2c5654be..db1ca265 100644 --- a/acme/http_test.go +++ b/acme/http_test.go @@ -55,7 +55,6 @@ func TestHTTPUserAgent(t *testing.T) { func TestUserAgent(t *testing.T) { ua := userAgent() - assert.Contains(t, ua, defaultGoUserAgent) assert.Contains(t, ua, ourUserAgent) if strings.HasSuffix(ua, " ") { t.Errorf("UA should not have trailing spaces; got '%s'", ua) @@ -65,7 +64,6 @@ func TestUserAgent(t *testing.T) { UserAgent = "MyApp/1.2.3" ua = userAgent() - assert.Contains(t, ua, defaultGoUserAgent) assert.Contains(t, ua, ourUserAgent) assert.Contains(t, ua, UserAgent) }