requestbody: Return HTTP 413 (fix #4558)

This commit is contained in:
Matthew Holt 2022-03-11 12:34:55 -07:00
parent b82e22b459
commit 3d616e8c6d
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
4 changed files with 25 additions and 8 deletions

View file

@ -17,6 +17,7 @@ package caddyhttp
import (
"context"
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
@ -600,7 +601,8 @@ func PrepareRequest(r *http.Request, repl *caddy.Replacer, w http.ResponseWriter
// If err is a HandlerError, the returned values will
// have richer information.
func errLogValues(err error) (status int, msg string, fields []zapcore.Field) {
if handlerErr, ok := err.(HandlerError); ok {
var handlerErr HandlerError
if errors.As(err, &handlerErr) {
status = handlerErr.StatusCode
if handlerErr.Err == nil {
msg = err.Error()