diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-03-05 10:24:48 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-03-05 10:24:15 +0000 |
| commit | e8bb9a578f890d64e19149f76063687f123a0a11 (patch) | |
| tree | b05ec2ec7530321c008eb9feae6319cc5110f206 | |
| parent | 538134649460ba510732bdcabcb83794373863a1 (diff) | |
syz-manager/http.go: support many content types in httpCoverCover
| -rw-r--r-- | syz-manager/http.go | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/syz-manager/http.go b/syz-manager/http.go index 11b6c60c5..ad00141bf 100644 --- a/syz-manager/http.go +++ b/syz-manager/http.go @@ -279,6 +279,8 @@ func (mgr *Manager) httpModuleCover(w http.ResponseWriter, r *http.Request) { mgr.httpCoverCover(w, r, DoModuleCover) } +const ctTextPlain = "text/plain; charset=utf-8" + func (mgr *Manager) httpCoverCover(w http.ResponseWriter, r *http.Request, funcFlag int) { if !mgr.cfg.Cover { http.Error(w, "coverage is not enabled", http.StatusInternalServerError) @@ -352,20 +354,20 @@ func (mgr *Manager) httpCoverCover(w http.ResponseWriter, r *http.Request, funcF type handlerFuncType func(w io.Writer, params cover.CoverHandlerParams) error flagToFunc := map[int]struct { Do handlerFuncType - isPlainText bool + contentType string }{ - DoHTML: {rg.DoHTML, false}, - DoHTMLTable: {rg.DoHTMLTable, false}, - DoModuleCover: {rg.DoModuleCover, false}, - DoCSV: {rg.DoCSV, true}, - DoCSVFiles: {rg.DoCSVFiles, true}, - DoRawCoverFiles: {rg.DoRawCoverFiles, true}, - DoRawCover: {rg.DoRawCover, true}, - DoFilterPCs: {rg.DoFilterPCs, true}, + DoHTML: {rg.DoHTML, ""}, + DoHTMLTable: {rg.DoHTMLTable, ""}, + DoModuleCover: {rg.DoModuleCover, ""}, + DoCSV: {rg.DoCSV, ctTextPlain}, + DoCSVFiles: {rg.DoCSVFiles, ctTextPlain}, + DoRawCoverFiles: {rg.DoRawCoverFiles, ctTextPlain}, + DoRawCover: {rg.DoRawCover, ctTextPlain}, + DoFilterPCs: {rg.DoFilterPCs, ctTextPlain}, } - if flagToFunc[funcFlag].isPlainText { - w.Header().Set("Content-Type", "text/plain; charset=utf-8") + if ct := flagToFunc[funcFlag].contentType; ct != "" { + w.Header().Set("Content-Type", ct) } if err := flagToFunc[funcFlag].Do(w, params); err != nil { |
