net/http/pprof: set content type for /debug/pprof

Fixes #37311

Change-Id: I9e1f37e991e5c203fe72061692f47584fbadfc58
Reviewed-on: https://go-review.googlesource.com/c/go/+/220324
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This commit is contained in:
Hana (Hyang-Ah) Kim 2020-02-20 17:25:33 -05:00 committed by Hyang-Ah Hana Kim
parent 6c61a57cfc
commit f5ff00583f
2 changed files with 4 additions and 0 deletions

View File

@ -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

View File

@ -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) {