mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Ensure we set a content-type for healthz
Change-Id: I453b1433c69bf26c28da873dbdd1ac25006b8d60 Co-Authored-By: Tim Allclair (St. Clair) <tallclair@google.com>
This commit is contained in:
parent
76e9089d0e
commit
eedb70355a
@ -185,6 +185,8 @@ func handleRootHealthz(checks ...HealthzChecker) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
if _, found := r.URL.Query()["verbose"]; !found {
|
||||
fmt.Fprint(w, "ok")
|
||||
return
|
||||
|
@ -40,6 +40,10 @@ func TestInstallHandler(t *testing.T) {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Errorf("expected %v, got %v", http.StatusOK, w.Code)
|
||||
}
|
||||
c := w.Header().Get("Content-Type")
|
||||
if c != "text/plain; charset=utf-8" {
|
||||
t.Errorf("expected %v, got %v", "text/plain", c)
|
||||
}
|
||||
if w.Body.String() != "ok" {
|
||||
t.Errorf("expected %v, got %v", "ok", w.Body.String())
|
||||
}
|
||||
@ -58,6 +62,10 @@ func TestInstallPathHandler(t *testing.T) {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Errorf("expected %v, got %v", http.StatusOK, w.Code)
|
||||
}
|
||||
c := w.Header().Get("Content-Type")
|
||||
if c != "text/plain; charset=utf-8" {
|
||||
t.Errorf("expected %v, got %v", "text/plain", c)
|
||||
}
|
||||
if w.Body.String() != "ok" {
|
||||
t.Errorf("expected %v, got %v", "ok", w.Body.String())
|
||||
}
|
||||
@ -71,6 +79,10 @@ func TestInstallPathHandler(t *testing.T) {
|
||||
if w.Code != http.StatusOK {
|
||||
t.Errorf("expected %v, got %v", http.StatusOK, w.Code)
|
||||
}
|
||||
c = w.Header().Get("Content-Type")
|
||||
if c != "text/plain; charset=utf-8" {
|
||||
t.Errorf("expected %v, got %v", "text/plain", c)
|
||||
}
|
||||
if w.Body.String() != "ok" {
|
||||
t.Errorf("expected %v, got %v", "ok", w.Body.String())
|
||||
}
|
||||
@ -120,6 +132,10 @@ func testMultipleChecks(path string, t *testing.T) {
|
||||
if w.Code != test.expectedStatus {
|
||||
t.Errorf("case[%d] Expected: %v, got: %v", i, test.expectedStatus, w.Code)
|
||||
}
|
||||
c := w.Header().Get("Content-Type")
|
||||
if c != "text/plain; charset=utf-8" {
|
||||
t.Errorf("case[%d] Expected: %v, got: %v", i, "text/plain", c)
|
||||
}
|
||||
if w.Body.String() != test.expectedResponse {
|
||||
t.Errorf("case[%d] Expected:\n%v\ngot:\n%v\n", i, test.expectedResponse, w.Body.String())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user