forked from TrueCloudLab/lego
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.
This commit is contained in:
parent
09a3292757
commit
a5f0a3ff80
2 changed files with 8 additions and 8 deletions
14
acme/http.go
14
acme/http.go
|
@ -42,12 +42,14 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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 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
|
// caCertificatesEnvVar is the environment variable name that can be used to
|
||||||
// specify the path to PEM encoded CA Certificates 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.
|
// userAgent builds and returns the User-Agent string to use in requests.
|
||||||
func userAgent() string {
|
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)
|
return strings.TrimSpace(ua)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ func TestHTTPUserAgent(t *testing.T) {
|
||||||
func TestUserAgent(t *testing.T) {
|
func TestUserAgent(t *testing.T) {
|
||||||
ua := userAgent()
|
ua := userAgent()
|
||||||
|
|
||||||
assert.Contains(t, ua, defaultGoUserAgent)
|
|
||||||
assert.Contains(t, ua, ourUserAgent)
|
assert.Contains(t, ua, ourUserAgent)
|
||||||
if strings.HasSuffix(ua, " ") {
|
if strings.HasSuffix(ua, " ") {
|
||||||
t.Errorf("UA should not have trailing spaces; got '%s'", 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"
|
UserAgent = "MyApp/1.2.3"
|
||||||
ua = userAgent()
|
ua = userAgent()
|
||||||
|
|
||||||
assert.Contains(t, ua, defaultGoUserAgent)
|
|
||||||
assert.Contains(t, ua, ourUserAgent)
|
assert.Contains(t, ua, ourUserAgent)
|
||||||
assert.Contains(t, ua, UserAgent)
|
assert.Contains(t, ua, UserAgent)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue