Return status 413 Request Entity Too Large where appropriate.

This commit is contained in:
Catherine
2025-09-21 03:33:00 +00:00
parent d2d4a27667
commit 403821a150

View File

@@ -432,6 +432,12 @@ func ServePages(w http.ResponseWriter, r *http.Request) {
http.Error(w, strings.ReplaceAll(message, "\n", "\n- "), authErr.code)
err = errors.New(strings.ReplaceAll(message, "\n", "; "))
}
var tooLargeErr *http.MaxBytesError
if errors.As(err, &tooLargeErr) {
message := "request body too large"
http.Error(w, message, http.StatusRequestEntityTooLarge)
err = errors.New(message)
}
log.Println("pages err:", err)
}
}