Merge pull request #5076 from satnam6502/redirect

Fix implementation of REDIRECT
This commit is contained in:
Daniel Smith 2015-03-04 17:53:41 -08:00
commit 6bd842676d
2 changed files with 4 additions and 3 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
package apiserver package apiserver
import ( import (
"fmt"
"net/http" "net/http"
"time" "time"
@ -85,7 +86,7 @@ func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return return
} }
w.Header().Set("Location", location) w.Header().Set("Location", fmt.Sprintf("http://%s", location))
w.WriteHeader(http.StatusTemporaryRedirect) w.WriteHeader(http.StatusTemporaryRedirect)
httpCode = http.StatusTemporaryRedirect httpCode = http.StatusTemporaryRedirect
} }

View File

@ -71,7 +71,7 @@ func TestRedirect(t *testing.T) {
if err == nil || err.(*url.Error).Err != dontFollow { if err == nil || err.(*url.Error).Err != dontFollow {
t.Errorf("Unexpected err %#v", err) 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) 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 { if err == nil || err.(*url.Error).Err != dontFollow {
t.Errorf("Unexpected err %#v", err) 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) t.Errorf("Expected %v, got %v", e, a)
} }
} }