From 411d1561fe40527ed261a224a1f9830a1ce705a1 Mon Sep 17 00:00:00 2001 From: ajay <89457471+4zore4@users.noreply.github.com> Date: Sun, 29 Sep 2024 14:57:32 +0800 Subject: [PATCH] fix: redirect /debug/pprof to avoid jumping to a blank page in httpd and meta service (#45) * bugfix:Add a redirect form /debug/pprof to /debug/pprof * chore: modify the comment of redirecting to /debug/pprof * fix(meta): redirect /debug/pprof to avoid jumping to a blank page in meta service * chore: update status code 302 to 307 in /debug/pprof --------- Co-authored-by: xiejunqiao Co-authored-by: Shiwen Cheng --- services/httpd/pprof.go | 4 ++++ services/meta/pprof.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/services/httpd/pprof.go b/services/httpd/pprof.go index 846d113..b7335f2 100644 --- a/services/httpd/pprof.go +++ b/services/httpd/pprof.go @@ -29,6 +29,10 @@ func (h *Handler) handleProfiles(w http.ResponseWriter, r *http.Request) { httppprof.Symbol(w, r) case "/debug/pprof/all": h.archiveProfilesAndQueries(w, r) + case "/debug/pprof": + // Redirect to /debug/pprof/ to avoid jumping to a blank page + // after clicking the links on the /debug/pprof webpage. + http.Redirect(w, r, "/debug/pprof/", http.StatusTemporaryRedirect) default: httppprof.Index(w, r) } diff --git a/services/meta/pprof.go b/services/meta/pprof.go index f53944b..d8a9088 100644 --- a/services/meta/pprof.go +++ b/services/meta/pprof.go @@ -25,6 +25,10 @@ func (h *handler) handleProfiles(w http.ResponseWriter, r *http.Request) { httppprof.Symbol(w, r) case "/debug/pprof/all": h.archiveProfiles(w, r) + case "/debug/pprof": + // Redirect to /debug/pprof/ to avoid jumping to a blank page + // after clicking the links on the /debug/pprof webpage. + http.Redirect(w, r, "/debug/pprof/", http.StatusTemporaryRedirect) default: httppprof.Index(w, r) }