From 51a55d31462e77337d222ccd2d56f7c60d21d518 Mon Sep 17 00:00:00 2001 From: Claire Li Date: Mon, 3 Nov 2014 22:19:25 -0800 Subject: [PATCH] Refactor formatURL in health/http.go --- pkg/health/http.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/health/http.go b/pkg/health/http.go index 69b8330fb8..c2d683dea7 100644 --- a/pkg/health/http.go +++ b/pkg/health/http.go @@ -18,7 +18,9 @@ package health import ( "fmt" + "net" "net/http" + "net/url" "strconv" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" @@ -76,7 +78,12 @@ func getURLParts(currentState api.PodState, container api.Container) (string, in // formatURL formats a URL from args. For testability. func formatURL(host string, port int, path string) string { - return fmt.Sprintf("http://%s:%d%s", host, port, path) + u := url.URL{ + Scheme: "http", + Host: net.JoinHostPort(host, strconv.Itoa(port)), + Path: path, + } + return u.String() } // DoHTTPCheck checks if a GET request to the url succeeds.