diff --git a/app/vmagent/main.go b/app/vmagent/main.go index 8e46d4624..7079c6b08 100644 --- a/app/vmagent/main.go +++ b/app/vmagent/main.go @@ -236,26 +236,26 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { return true } // See https://docs.datadoghq.com/api/latest/metrics/#submit-metrics - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true case "/datadog/api/v1/validate": datadogValidateRequests.Inc() // See https://docs.datadoghq.com/api/latest/authentication/#validate-api-key - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{"valid":true}`) return true case "/datadog/api/v1/check_run": datadogCheckRunRequests.Inc() // See https://docs.datadoghq.com/api/latest/service-checks/#submit-a-service-check - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true case "/datadog/intake/": datadogIntakeRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{}`) return true case "/targets": @@ -277,7 +277,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { return true case "/api/v1/targets": promscrapeAPIV1TargetsRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") state := r.FormValue("state") promscrape.WriteAPIV1Targets(w, state) return true @@ -391,19 +391,19 @@ func processMultitenantRequest(w http.ResponseWriter, r *http.Request, path stri case "datadog/api/v1/validate": datadogValidateRequests.Inc() // See https://docs.datadoghq.com/api/latest/authentication/#validate-api-key - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{"valid":true}`) return true case "datadog/api/v1/check_run": datadogCheckRunRequests.Inc() // See https://docs.datadoghq.com/api/latest/service-checks/#submit-a-service-check - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true case "datadog/intake/": datadogIntakeRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{}`) return true default: diff --git a/app/vmalert/datasource/vm.go b/app/vmalert/datasource/vm.go index 304d88cec..c900ed2f6 100644 --- a/app/vmalert/datasource/vm.go +++ b/app/vmalert/datasource/vm.go @@ -150,7 +150,7 @@ func (s *VMStorage) newRequestPOST() (*http.Request, error) { if err != nil { return nil, err } - req.Header.Set("Content-Type", "application/json; charset=utf-8") + req.Header.Set("Content-Type", "application/json") if s.authCfg != nil { if auth := s.authCfg.GetAuthHeader(); auth != "" { req.Header.Set("Authorization", auth) diff --git a/app/vmalert/notifier/alertmanager.go b/app/vmalert/notifier/alertmanager.go index 36b75cfbb..cf132f828 100644 --- a/app/vmalert/notifier/alertmanager.go +++ b/app/vmalert/notifier/alertmanager.go @@ -32,7 +32,7 @@ func (am *AlertManager) Send(ctx context.Context, alerts []Alert) error { if err != nil { return err } - req.Header.Set("Content-Type", "application/json; charset=utf-8") + req.Header.Set("Content-Type", "application/json") req = req.WithContext(ctx) if am.basicAuthPass != "" { req.SetBasicAuth(am.basicAuthUser, am.basicAuthPass) diff --git a/app/vmalert/web.go b/app/vmalert/web.go index e1034dab7..5100d0e36 100644 --- a/app/vmalert/web.go +++ b/app/vmalert/web.go @@ -68,7 +68,7 @@ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool { httpserver.Errorf(w, r, "%s", err) return true } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.Write(data) return true case "/api/v1/alerts": @@ -77,7 +77,7 @@ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool { httpserver.Errorf(w, r, "%s", err) return true } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.Write(data) return true case "/-/reload": @@ -102,7 +102,7 @@ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool { httpserver.Errorf(w, r, "failed to marshal alert: %s", err) return true } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.Write(data) return true } diff --git a/app/vminsert/main.go b/app/vminsert/main.go index fdf137249..a16dbceaf 100644 --- a/app/vminsert/main.go +++ b/app/vminsert/main.go @@ -254,26 +254,26 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { return true } // See https://docs.datadoghq.com/api/latest/metrics/#submit-metrics - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true case "datadog/api/v1/validate": datadogValidateRequests.Inc() // See https://docs.datadoghq.com/api/latest/authentication/#validate-api-key - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{"valid":true}`) return true case "datadog/api/v1/check_run": datadogCheckRunRequests.Inc() // See https://docs.datadoghq.com/api/latest/service-checks/#submit-a-service-check - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") w.WriteHeader(202) fmt.Fprintf(w, `{"status":"ok"}`) return true case "datadog/intake/": datadogIntakeRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{}`) return true default: diff --git a/app/vmselect/graphite/metrics_api.go b/app/vmselect/graphite/metrics_api.go index 465dff496..6f2ac5f76 100644 --- a/app/vmselect/graphite/metrics_api.go +++ b/app/vmselect/graphite/metrics_api.go @@ -468,7 +468,7 @@ const maxRegexpCacheSize = 10000 func getContentType(jsonp string) string { if jsonp == "" { - return "application/json; charset=utf-8" + return "application/json" } return "text/javascript; charset=utf-8" } diff --git a/app/vmselect/graphite/tags_api.go b/app/vmselect/graphite/tags_api.go index 4d3a87da8..ffe5cc7a7 100644 --- a/app/vmselect/graphite/tags_api.go +++ b/app/vmselect/graphite/tags_api.go @@ -62,7 +62,7 @@ func TagsDelSeriesHandler(startTime time.Time, at *auth.Token, w http.ResponseWr totalDeleted += n } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") if totalDeleted > 0 { fmt.Fprintf(w, "true") } else { @@ -142,7 +142,7 @@ func registerMetrics(startTime time.Time, at *auth.Token, w http.ResponseWriter, // Return response contentType := "text/plain; charset=utf-8" if isJSONResponse { - contentType = "application/json; charset=utf-8" + contentType = "application/json" } w.Header().Set("Content-Type", contentType) WriteTagsTagMultiSeriesResponse(w, canonicalPaths, isJSONResponse) @@ -370,7 +370,7 @@ func TagsFindSeriesHandler(startTime time.Time, at *auth.Token, w http.ResponseW paths = paths[:limit] } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteTagsFindSeriesResponse(bw, isPartial, paths) @@ -427,7 +427,7 @@ func TagValuesHandler(startTime time.Time, at *auth.Token, tagName string, w htt return err } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteTagValuesResponse(bw, isPartial, tagName, tagValues) @@ -459,7 +459,7 @@ func TagsHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r * return err } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteTagsResponse(bw, isPartial, labels) diff --git a/app/vmselect/main.go b/app/vmselect/main.go index 27aee9f7c..9f4d82eda 100644 --- a/app/vmselect/main.go +++ b/app/vmselect/main.go @@ -305,7 +305,7 @@ func selectHandler(startTime time.Time, w http.ResponseWriter, r *http.Request, } if strings.HasPrefix(p.Suffix, "graphite/functions") { graphiteFunctionsRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, "%s", `{}`) return true } @@ -505,25 +505,25 @@ func selectHandler(startTime time.Time, w http.ResponseWriter, r *http.Request, case "prometheus/api/v1/rules", "prometheus/rules": // Return dumb placeholder for https://prometheus.io/docs/prometheus/latest/querying/api/#rules rulesRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, "%s", `{"status":"success","data":{"groups":[]}}`) return true case "prometheus/api/v1/alerts", "prometheus/alerts": // Return dumb placeholder for https://prometheus.io/docs/prometheus/latest/querying/api/#alerts alertsRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, "%s", `{"status":"success","data":{"alerts":[]}}`) return true case "prometheus/api/v1/metadata": // Return dumb placeholder for https://prometheus.io/docs/prometheus/latest/querying/api/#querying-metric-metadata metadataRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, "%s", `{"status":"success","data":{}}`) return true case "prometheus/api/v1/query_exemplars": // Return dumb placeholder for https://prometheus.io/docs/prometheus/latest/querying/api/#querying-exemplars queryExemplarsRequests.Inc() - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, "%s", `{"status":"success","data":null}`) return true default: @@ -562,7 +562,7 @@ func isGraphiteTagsPath(path string) bool { func sendPrometheusError(w http.ResponseWriter, r *http.Request, err error) { logger.Warnf("error in %q: %s", httpserver.GetRequestURI(r), err) - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") statusCode := http.StatusUnprocessableEntity var esc *httpserver.ErrorWithStatusCode if errors.As(err, &esc) { diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index c9303a4fa..2c63cc10d 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -590,7 +590,7 @@ func LabelValuesHandler(startTime time.Time, at *auth.Token, labelName string, w } } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteLabelValuesResponse(bw, isPartial, labelValues) @@ -685,7 +685,7 @@ func LabelsCountHandler(startTime time.Time, at *auth.Token, w http.ResponseWrit return fmt.Errorf(`cannot obtain label entries: %w`, err) } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteLabelsCountResponse(bw, isPartial, labelEntries) @@ -756,7 +756,7 @@ func TSDBStatusHandler(startTime time.Time, at *auth.Token, w http.ResponseWrite } } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteTSDBStatusResponse(bw, isPartial, status) @@ -852,7 +852,7 @@ func LabelsHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r } } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteLabelsResponse(bw, isPartial, labels) @@ -933,7 +933,7 @@ func SeriesCountHandler(startTime time.Time, at *auth.Token, w http.ResponseWrit return fmt.Errorf("cannot obtain series count: %w", err) } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteSeriesCountResponse(bw, isPartial, n) @@ -985,7 +985,7 @@ func SeriesHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r if err != nil { return fmt.Errorf("cannot fetch time series for %q: %w", sq, err) } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) resultsCh := make(chan *quicktemplate.ByteBuffer) @@ -1010,7 +1010,7 @@ func SeriesHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r return fmt.Errorf("cannot fetch data for %q: %w", sq, err) } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) resultsCh := make(chan *quicktemplate.ByteBuffer) @@ -1147,7 +1147,7 @@ func QueryHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r } } - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteQueryResponse(bw, ec.IsPartialResponse, result) @@ -1243,7 +1243,7 @@ func queryRangeHandler(startTime time.Time, at *auth.Token, w http.ResponseWrite // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/153 result = removeEmptyValuesAndTimeseries(result) - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) WriteQueryRangeResponse(bw, ec.IsPartialResponse, result) @@ -1423,7 +1423,7 @@ func QueryStatsHandler(startTime time.Time, at *auth.Token, w http.ResponseWrite return fmt.Errorf("cannot parse `maxLifetime` arg: %w", err) } maxLifetime := time.Duration(maxLifetimeMsecs) * time.Millisecond - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) if at == nil { diff --git a/app/vmstorage/main.go b/app/vmstorage/main.go index a9bb2a43c..1939d6ed2 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -182,7 +182,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request, strg *storage.Storag switch path { case "/create": - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") snapshotPath, err := strg.CreateSnapshot() if err != nil { err = fmt.Errorf("cannot create snapshot: %w", err) @@ -192,7 +192,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request, strg *storage.Storag fmt.Fprintf(w, `{"status":"ok","snapshot":%q}`, snapshotPath) return true case "/list": - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") snapshots, err := strg.ListSnapshots() if err != nil { err = fmt.Errorf("cannot list snapshots: %w", err) @@ -209,7 +209,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request, strg *storage.Storag fmt.Fprintf(w, `]}`) return true case "/delete": - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") snapshotName := r.FormValue("snapshot") if err := strg.DeleteSnapshot(snapshotName); err != nil { err = fmt.Errorf("cannot delete snapshot %q: %w", snapshotName, err) @@ -219,7 +219,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request, strg *storage.Storag fmt.Fprintf(w, `{"status":"ok"}`) return true case "/delete_all": - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") snapshots, err := strg.ListSnapshots() if err != nil { err = fmt.Errorf("cannot list snapshots: %w", err) diff --git a/lib/influxutils/influxutils.go b/lib/influxutils/influxutils.go index f441ddd49..0350b0102 100644 --- a/lib/influxutils/influxutils.go +++ b/lib/influxutils/influxutils.go @@ -16,7 +16,7 @@ func WriteDatabaseNames(w http.ResponseWriter) { // Emulate fake response for influx query. // This is required for TSBS benchmark and some Telegraf plugins. // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1124 - w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.Header().Set("Content-Type", "application/json") dbNames := *influxDatabaseNames if len(dbNames) == 0 { dbNames = []string{"_internal"}