]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/pprof: set content type for /debug/pprof
authorHana (Hyang-Ah) Kim <hyangah@gmail.com>
Thu, 20 Feb 2020 22:25:33 +0000 (17:25 -0500)
committerHyang-Ah Hana Kim <hyangah@gmail.com>
Fri, 21 Feb 2020 19:28:40 +0000 (19:28 +0000)
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>
src/net/http/pprof/pprof.go
src/net/http/pprof/pprof_test.go

index a237f58609c1c3e747ad11658cd7071371ae2831..5c33916fbae6688ecda60342135c34c3b4831ce0 100644 (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
index dbb6fef15923c336b0a5841ec7f98a66c71a6877..61f39b7782a4df84a1d7641a6ffbbc38fe534795 100644 (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) {