Skip to content

Commit a5f0a3f

Browse files
jshaldez
authored andcommitted
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.
1 parent 09a3292 commit a5f0a3f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

acme/http.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ var (
4242
)
4343

4444
const (
45-
// defaultGoUserAgent is the Go HTTP package user agent string. Too
46-
// bad it isn't exported. If it changes, we should update it here, too.
47-
defaultGoUserAgent = "Go-http-client/1.1"
48-
4945
// ourUserAgent is the User-Agent of this underlying library package.
50-
ourUserAgent = "xenolf-acme"
46+
// NOTE: Update this with each tagged release.
47+
ourUserAgent = "xenolf-acme/1.2.1"
48+
49+
// ourUserAgentComment is part of the UA comment linked to the version status of this underlying library package.
50+
// values: detach|release
51+
// NOTE: Update this with each tagged release.
52+
ourUserAgentComment = "detach"
5153

5254
// caCertificatesEnvVar is the environment variable name that can be used to
5355
// 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
205207

206208
// userAgent builds and returns the User-Agent string to use in requests.
207209
func userAgent() string {
208-
ua := fmt.Sprintf("%s %s (%s; %s) %s", UserAgent, ourUserAgent, runtime.GOOS, runtime.GOARCH, defaultGoUserAgent)
210+
ua := fmt.Sprintf("%s %s (%s; %s; %s)", UserAgent, ourUserAgent, ourUserAgentComment, runtime.GOOS, runtime.GOARCH)
209211
return strings.TrimSpace(ua)
210212
}

acme/http_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func TestHTTPUserAgent(t *testing.T) {
5555
func TestUserAgent(t *testing.T) {
5656
ua := userAgent()
5757

58-
assert.Contains(t, ua, defaultGoUserAgent)
5958
assert.Contains(t, ua, ourUserAgent)
6059
if strings.HasSuffix(ua, " ") {
6160
t.Errorf("UA should not have trailing spaces; got '%s'", ua)
@@ -65,7 +64,6 @@ func TestUserAgent(t *testing.T) {
6564
UserAgent = "MyApp/1.2.3"
6665
ua = userAgent()
6766

68-
assert.Contains(t, ua, defaultGoUserAgent)
6967
assert.Contains(t, ua, ourUserAgent)
7068
assert.Contains(t, ua, UserAgent)
7169
}

0 commit comments

Comments
 (0)