From 3d616e8c6d65e5617f5a918d72fb1514c9c7144e Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 11 Mar 2022 12:34:55 -0700 Subject: requestbody: Return HTTP 413 (fix #4558) --- modules/caddyhttp/replacer.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'modules/caddyhttp/replacer.go') diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go index 26f7e0b..d3fa891 100644 --- a/modules/caddyhttp/replacer.go +++ b/modules/caddyhttp/replacer.go @@ -162,12 +162,8 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo // read the request body into a buffer (can't pool because we // don't know its lifetime and would have to make a copy anyway) buf := new(bytes.Buffer) - _, err := io.Copy(buf, req.Body) - if err != nil { - return "", true - } - // replace real body with buffered data - req.Body = io.NopCloser(buf) + _, _ = io.Copy(buf, req.Body) // can't handle error, so just ignore it + req.Body = io.NopCloser(buf) // replace real body with buffered data return buf.String(), true // original request, before any internal changes -- cgit v1.2.3