tsweb: jsonhandler: fix content type

Signed-off-by: Zijie Lu <zijie@tailscale.com>
reviewable/pr556/r1
Zijie Lu 4 years ago
parent 23123907c0
commit c9e40abfb8

@ -32,8 +32,8 @@ func responseError(e string) *response {
func writeResponse(w http.ResponseWriter, s int, resp *response) {
b, _ := json.Marshal(resp)
w.WriteHeader(s)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(s)
w.Write(b)
}

@ -44,6 +44,10 @@ func TestNewJSONHandler(t *testing.T) {
t.Fatalf("wrong status: %s %s", d.Status, status)
}
if w.Header().Get("Content-Type") != "application/json" {
t.Fatalf("wrong content type: %s", w.Header().Get("Content-Type"))
}
return d
}

Loading…
Cancel
Save