From 823e88d4c4298c38130b9a387a45c47cf957a931 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 11 Aug 2017 10:47:02 -0700 Subject: [PATCH] Fix requests for docker host ending with slash Signed-off-by: Tonis Tiigi --- client/client.go | 5 +++-- client/ping.go | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/client.go b/client/client.go index c4e3914b1e..f7a8c07d3a 100644 --- a/client/client.go +++ b/client/client.go @@ -51,6 +51,7 @@ import ( "net/http" "net/url" "os" + "path" "path/filepath" "strings" @@ -219,9 +220,9 @@ func (cli *Client) getAPIPath(p string, query url.Values) string { var apiPath string if cli.version != "" { v := strings.TrimPrefix(cli.version, "v") - apiPath = cli.basePath + "/v" + v + p + apiPath = path.Join(cli.basePath, "/v"+v+p) } else { - apiPath = cli.basePath + p + apiPath = path.Join(cli.basePath, p) } u := &url.URL{ diff --git a/client/ping.go b/client/ping.go index a4c2e2c4dd..8501375c88 100644 --- a/client/ping.go +++ b/client/ping.go @@ -1,6 +1,8 @@ package client import ( + "path" + "github.com/docker/docker/api/types" "golang.org/x/net/context" ) @@ -8,7 +10,7 @@ import ( // Ping pings the server and returns the value of the "Docker-Experimental", "OS-Type" & "API-Version" headers func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { var ping types.Ping - req, err := cli.buildRequest("GET", cli.basePath+"/_ping", nil, nil) + req, err := cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil) if err != nil { return ping, err }