From 123ca7de53be1b6f7b6630c7466e66c359549996 Mon Sep 17 00:00:00 2001 From: Satnam Singh Date: Wed, 4 Mar 2015 14:51:16 -0800 Subject: [PATCH] Specify HTTP for REDIRECT --- pkg/apiserver/redirect.go | 3 ++- pkg/apiserver/redirect_test.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/apiserver/redirect.go b/pkg/apiserver/redirect.go index 5267c4cd296fd..6dbfc64d4e735 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 4098671f961df..cc3edaa28760b 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) } }