aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/pprof
diff options
context:
space:
mode:
authorHana (Hyang-Ah) Kim <hyangah@gmail.com>2020-02-20 17:25:33 -0500
committerHyang-Ah Hana Kim <hyangah@gmail.com>2020-02-21 19:28:40 +0000
commitf5ff00583fa6d4e9b4acb98b96757d98b1f55d28 (patch)
treeca2766e1374bbc89c0b167d5c16c43121186c96b /src/net/http/pprof
parent6c61a57cfc24d344529685977855341ae9f17239 (diff)
downloadgo-f5ff00583fa6d4e9b4acb98b96757d98b1f55d28.tar.xz
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>
Diffstat (limited to 'src/net/http/pprof')
-rw-r--r--src/net/http/pprof/pprof.go3
-rw-r--r--src/net/http/pprof/pprof_test.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/src/net/http/pprof/pprof.go b/src/net/http/pprof/pprof.go
index a237f58609..5c33916fba 100644
--- a/src/net/http/pprof/pprof.go
+++ b/src/net/http/pprof/pprof.go
@@ -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
diff --git a/src/net/http/pprof/pprof_test.go b/src/net/http/pprof/pprof_test.go
index dbb6fef159..61f39b7782 100644
--- a/src/net/http/pprof/pprof_test.go
+++ b/src/net/http/pprof/pprof_test.go
@@ -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) {