mirror of https://github.com/golang/go.git
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:
parent
6c61a57cfc
commit
f5ff00583f
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue