mirror of https://github.com/k3s-io/k3s
Merge pull request #72520 from dims/add-content-type-for-healthz-response
Ensure we set a content-type for healthzpull/564/head
commit
08d7030f62
|
@ -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