Browse Source

trace: properly set the content type when sending html

Without this, if the responses are compressed, Chrome's content-type
detection will fail and it will attempt to download these pages rather
than render them as HTML.

Change-Id: Ib5f803f335d55a00a759de85d38855ee0ae13ee0
Reviewed-on: https://go-review.googlesource.com/18230
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Tamir Duberstein 10 năm trước cách đây
mục cha
commit
0ab009005d
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      trace/trace.go

+ 3 - 1
trace/trace.go

@@ -113,6 +113,7 @@ func init() {
 			http.Error(w, "not allowed", http.StatusUnauthorized)
 			return
 		}
+		w.Header().Set("Content-Type", "text/html; charset=utf-8")
 		Render(w, req, sensitive)
 	})
 	http.HandleFunc("/debug/events", func(w http.ResponseWriter, req *http.Request) {
@@ -121,6 +122,7 @@ func init() {
 			http.Error(w, "not allowed", http.StatusUnauthorized)
 			return
 		}
+		w.Header().Set("Content-Type", "text/html; charset=utf-8")
 		RenderEvents(w, req, sensitive)
 	})
 }
@@ -172,7 +174,7 @@ func Render(w io.Writer, req *http.Request, sensitive bool) {
 
 	completedMu.RLock()
 	data.Families = make([]string, 0, len(completedTraces))
-	for fam, _ := range completedTraces {
+	for fam := range completedTraces {
 		data.Families = append(data.Families, fam)
 	}
 	completedMu.RUnlock()