diff --git a/pkg/apiserver/redirect.go b/pkg/apiserver/redirect.go index 5267c4cd296..6dbfc64d4e7 100644 --- a/pkg/apiserver/redirect.go +++ b/pkg/apiserver/redirect.go @@ -17,6 +17,7 @@ limitations under the License. package apiserver import ( + "fmt" "net/http" "time" @@ -85,7 +86,7 @@ func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - w.Header().Set("Location", location) + w.Header().Set("Location", fmt.Sprintf("http://%s", location)) w.WriteHeader(http.StatusTemporaryRedirect) httpCode = http.StatusTemporaryRedirect } diff --git a/pkg/apiserver/redirect_test.go b/pkg/apiserver/redirect_test.go index 4098671f961..cc3edaa2876 100644 --- a/pkg/apiserver/redirect_test.go +++ b/pkg/apiserver/redirect_test.go @@ -71,7 +71,7 @@ func TestRedirect(t *testing.T) { if err == nil || err.(*url.Error).Err != dontFollow { t.Errorf("Unexpected err %#v", err) } - if e, a := item.id, resp.Header.Get("Location"); e != a { + if e, a := "http://"+item.id, resp.Header.Get("Location"); e != a { t.Errorf("Expected %v, got %v", e, a) } } @@ -124,7 +124,7 @@ func TestRedirectWithNamespaces(t *testing.T) { if err == nil || err.(*url.Error).Err != dontFollow { t.Errorf("Unexpected err %#v", err) } - if e, a := item.id, resp.Header.Get("Location"); e != a { + if e, a := "http://"+item.id, resp.Header.Get("Location"); e != a { t.Errorf("Expected %v, got %v", e, a) } }