Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
08d7030f
Unverified
Commit
08d7030f
authored
Jan 10, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jan 10, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72520 from dims/add-content-type-for-healthz-response
Ensure we set a content-type for healthz
parents
b92756e8
eedb7035
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
healthz.go
staging/src/k8s.io/apiserver/pkg/server/healthz/healthz.go
+2
-0
healthz_test.go
...g/src/k8s.io/apiserver/pkg/server/healthz/healthz_test.go
+16
-0
No files found.
staging/src/k8s.io/apiserver/pkg/server/healthz/healthz.go
View file @
08d7030f
...
@@ -185,6 +185,8 @@ func handleRootHealthz(checks ...HealthzChecker) http.HandlerFunc {
...
@@ -185,6 +185,8 @@ func handleRootHealthz(checks ...HealthzChecker) http.HandlerFunc {
return
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
{
if
_
,
found
:=
r
.
URL
.
Query
()[
"verbose"
];
!
found
{
fmt
.
Fprint
(
w
,
"ok"
)
fmt
.
Fprint
(
w
,
"ok"
)
return
return
...
...
staging/src/k8s.io/apiserver/pkg/server/healthz/healthz_test.go
View file @
08d7030f
...
@@ -40,6 +40,10 @@ func TestInstallHandler(t *testing.T) {
...
@@ -40,6 +40,10 @@ func TestInstallHandler(t *testing.T) {
if
w
.
Code
!=
http
.
StatusOK
{
if
w
.
Code
!=
http
.
StatusOK
{
t
.
Errorf
(
"expected %v, got %v"
,
http
.
StatusOK
,
w
.
Code
)
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"
{
if
w
.
Body
.
String
()
!=
"ok"
{
t
.
Errorf
(
"expected %v, got %v"
,
"ok"
,
w
.
Body
.
String
())
t
.
Errorf
(
"expected %v, got %v"
,
"ok"
,
w
.
Body
.
String
())
}
}
...
@@ -58,6 +62,10 @@ func TestInstallPathHandler(t *testing.T) {
...
@@ -58,6 +62,10 @@ func TestInstallPathHandler(t *testing.T) {
if
w
.
Code
!=
http
.
StatusOK
{
if
w
.
Code
!=
http
.
StatusOK
{
t
.
Errorf
(
"expected %v, got %v"
,
http
.
StatusOK
,
w
.
Code
)
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"
{
if
w
.
Body
.
String
()
!=
"ok"
{
t
.
Errorf
(
"expected %v, got %v"
,
"ok"
,
w
.
Body
.
String
())
t
.
Errorf
(
"expected %v, got %v"
,
"ok"
,
w
.
Body
.
String
())
}
}
...
@@ -71,6 +79,10 @@ func TestInstallPathHandler(t *testing.T) {
...
@@ -71,6 +79,10 @@ func TestInstallPathHandler(t *testing.T) {
if
w
.
Code
!=
http
.
StatusOK
{
if
w
.
Code
!=
http
.
StatusOK
{
t
.
Errorf
(
"expected %v, got %v"
,
http
.
StatusOK
,
w
.
Code
)
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"
{
if
w
.
Body
.
String
()
!=
"ok"
{
t
.
Errorf
(
"expected %v, got %v"
,
"ok"
,
w
.
Body
.
String
())
t
.
Errorf
(
"expected %v, got %v"
,
"ok"
,
w
.
Body
.
String
())
}
}
...
@@ -120,6 +132,10 @@ func testMultipleChecks(path string, t *testing.T) {
...
@@ -120,6 +132,10 @@ func testMultipleChecks(path string, t *testing.T) {
if
w
.
Code
!=
test
.
expectedStatus
{
if
w
.
Code
!=
test
.
expectedStatus
{
t
.
Errorf
(
"case[%d] Expected: %v, got: %v"
,
i
,
test
.
expectedStatus
,
w
.
Code
)
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
{
if
w
.
Body
.
String
()
!=
test
.
expectedResponse
{
t
.
Errorf
(
"case[%d] Expected:
\n
%v
\n
got:
\n
%v
\n
"
,
i
,
test
.
expectedResponse
,
w
.
Body
.
String
())
t
.
Errorf
(
"case[%d] Expected:
\n
%v
\n
got:
\n
%v
\n
"
,
i
,
test
.
expectedResponse
,
w
.
Body
.
String
())
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment