Return status 415 Unsupported Media Type in PUT handler.

Before this commit, an unparseable media type would return 200 OK.
This commit is contained in:
Catherine
2025-09-21 03:26:17 +00:00
parent 5765fa7ffa
commit d2d4a27667

View File

@@ -185,7 +185,8 @@ func putPage(w http.ResponseWriter, r *http.Request) error {
contentType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return fmt.Errorf("parsing content type: %w", err)
http.Error(w, "malformed content type", http.StatusUnsupportedMediaType)
return fmt.Errorf("content type: %w", err)
}
if contentType == "application/x-www-form-urlencoded" {