Skip to content

Commit

Permalink
net/http/pprof: set content type for /debug/pprof
Browse files Browse the repository at this point in the history
Fixes #37311

Change-Id: I9e1f37e991e5c203fe72061692f47584fbadfc58
Reviewed-on: https://go-review.googlesource.com/c/go/+/220324
Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Emmanuel Odeke <[email protected]>
  • Loading branch information
hyangah committed Feb 21, 2020
1 parent 6c61a57 commit f5ff005
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/net/http/pprof/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ func Index(w http.ResponseWriter, r *http.Request) {
}
}

w.Header().Set("X-Content-Type-Options", "nosniff")
w.Header().Set("Content-Type", "text/html; charset=utf-8")

type profile struct {
Name string
Href string
Expand Down
1 change: 1 addition & 0 deletions src/net/http/pprof/pprof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestHandlers(t *testing.T) {
{"/debug/pprof/profile?seconds=1", Profile, http.StatusOK, "application/octet-stream", `attachment; filename="profile"`, nil},
{"/debug/pprof/symbol", Symbol, http.StatusOK, "text/plain; charset=utf-8", "", nil},
{"/debug/pprof/trace", Trace, http.StatusOK, "application/octet-stream", `attachment; filename="trace"`, nil},
{"/debug/pprof/", Index, http.StatusOK, "text/html; charset=utf-8", "", []byte("Types of profiles available:")},
}
for _, tc := range testCases {
t.Run(tc.path, func(t *testing.T) {
Expand Down

0 comments on commit f5ff005

Please sign in to comment.