1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

fix: Content-Type header for JSON responses

* Remove `charset=utf-8` parameter, which is not allowed
     for JSON, according to rfc8259.
This commit is contained in:
Bernhard Reiter 2024-12-18 08:55:48 +01:00
parent 1daaed2c51
commit 95ff418a27
No known key found for this signature in database
GPG key ID: 2B7BA3BF9BC3A554

View file

@ -174,7 +174,7 @@ func (c *controller) web(
// writeJSON sets the header for the response and writes the JSON encoding of the given "content". // writeJSON sets the header for the response and writes the JSON encoding of the given "content".
// It logs out an error message in case of an error. // It logs out an error message in case of an error.
func writeJSON(rw http.ResponseWriter, content any, code int) { func writeJSON(rw http.ResponseWriter, content any, code int) {
rw.Header().Set("Content-type", "application/json; charset=utf-8") rw.Header().Set("Content-type", "application/json")
rw.Header().Set("X-Content-Type-Options", "nosniff") rw.Header().Set("X-Content-Type-Options", "nosniff")
rw.WriteHeader(code) rw.WriteHeader(code)
if err := json.NewEncoder(rw).Encode(content); err != nil { if err := json.NewEncoder(rw).Encode(content); err != nil {