From d2d4a27667986e16c994f40af532ed018f2018ef Mon Sep 17 00:00:00 2001 From: Catherine Date: Sun, 21 Sep 2025 03:26:17 +0000 Subject: [PATCH] Return status 415 Unsupported Media Type in `PUT` handler. Before this commit, an unparseable media type would return 200 OK. --- src/pages.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages.go b/src/pages.go index 42dec45..15e88b0 100644 --- a/src/pages.go +++ b/src/pages.go @@ -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" {