Skip to content

Commit 0ab0090

Browse files
tamirdbradfitz
authored andcommitted
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 <[email protected]>
1 parent 0cb26f7 commit 0ab0090

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

trace/trace.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func init() {
113113
http.Error(w, "not allowed", http.StatusUnauthorized)
114114
return
115115
}
116+
w.Header().Set("Content-Type", "text/html; charset=utf-8")
116117
Render(w, req, sensitive)
117118
})
118119
http.HandleFunc("/debug/events", func(w http.ResponseWriter, req *http.Request) {
@@ -121,6 +122,7 @@ func init() {
121122
http.Error(w, "not allowed", http.StatusUnauthorized)
122123
return
123124
}
125+
w.Header().Set("Content-Type", "text/html; charset=utf-8")
124126
RenderEvents(w, req, sensitive)
125127
})
126128
}
@@ -172,7 +174,7 @@ func Render(w io.Writer, req *http.Request, sensitive bool) {
172174

173175
completedMu.RLock()
174176
data.Families = make([]string, 0, len(completedTraces))
175-
for fam, _ := range completedTraces {
177+
for fam := range completedTraces {
176178
data.Families = append(data.Families, fam)
177179
}
178180
completedMu.RUnlock()

0 commit comments

Comments
 (0)