Add GOOS in User-Agent

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard
2015-06-04 13:37:41 -07:00
committed by John Howard
parent b26428257f
commit 543cf79ffb
5 changed files with 20 additions and 3 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
req.Header.Set(k, v)
}
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION+" ("+runtime.GOOS+")")
req.Header.Set("Content-Type", "text/plain")
req.Header.Set("Connection", "Upgrade")
req.Header.Set("Upgrade", "tcp")
+1 -1
View File
@@ -64,7 +64,7 @@ func (cli *DockerCli) clientRequest(method, path string, in io.Reader, headers m
req.Header.Set(k, v)
}
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION+" ("+runtime.GOOS+")")
req.URL.Host = cli.addr
req.URL.Scheme = cli.scheme
+7
View File
@@ -1459,6 +1459,13 @@ func makeHttpHandler(logging bool, localMethod string, localRoute string, handle
if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") {
userAgent := strings.Split(r.Header.Get("User-Agent"), "/")
// v1.20 onwards includes the GOOS of the client after the version
// such as Docker/1.7.0 (linux)
if len(userAgent) == 2 && strings.Contains(userAgent[1], " ") {
userAgent[1] = strings.Split(userAgent[1], " ")[0]
}
if len(userAgent) == 2 && !dockerVersion.Equal(version.Version(userAgent[1])) {
logrus.Debugf("Warning: client and server don't have the same version (client: %s, server: %s)", userAgent[1], dockerVersion)
}