Skip to content

Commit 6bd8426

Browse files
committed
Merge pull request kubernetes#5076 from satnam6502/redirect
Fix implementation of REDIRECT
2 parents a85fa30 + 123ca7d commit 6bd8426

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pkg/apiserver/redirect.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package apiserver
1818

1919
import (
20+
"fmt"
2021
"net/http"
2122
"time"
2223

@@ -85,7 +86,7 @@ func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
8586
return
8687
}
8788

88-
w.Header().Set("Location", location)
89+
w.Header().Set("Location", fmt.Sprintf("http://%s", location))
8990
w.WriteHeader(http.StatusTemporaryRedirect)
9091
httpCode = http.StatusTemporaryRedirect
9192
}

pkg/apiserver/redirect_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestRedirect(t *testing.T) {
7171
if err == nil || err.(*url.Error).Err != dontFollow {
7272
t.Errorf("Unexpected err %#v", err)
7373
}
74-
if e, a := item.id, resp.Header.Get("Location"); e != a {
74+
if e, a := "http://"+item.id, resp.Header.Get("Location"); e != a {
7575
t.Errorf("Expected %v, got %v", e, a)
7676
}
7777
}
@@ -124,7 +124,7 @@ func TestRedirectWithNamespaces(t *testing.T) {
124124
if err == nil || err.(*url.Error).Err != dontFollow {
125125
t.Errorf("Unexpected err %#v", err)
126126
}
127-
if e, a := item.id, resp.Header.Get("Location"); e != a {
127+
if e, a := "http://"+item.id, resp.Header.Get("Location"); e != a {
128128
t.Errorf("Expected %v, got %v", e, a)
129129
}
130130
}

0 commit comments

Comments
 (0)