From e88a448a20c8a5c5c86877748bd5e23956aae9d8 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 6 Mar 2018 10:23:24 +0000 Subject: [PATCH] Read request body before sending response --- src/github.com/matrix-org/rageshake/submit.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/rageshake/submit.go b/src/github.com/matrix-org/rageshake/submit.go index 1d8d5fb..da2b37c 100644 --- a/src/github.com/matrix-org/rageshake/submit.go +++ b/src/github.com/matrix-org/rageshake/submit.go @@ -85,8 +85,9 @@ type submitResponse struct { func (s *submitServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { // if we attempt to return a response without reading the request body, - // haproxy gets upset and returns a 500. Let's try this. + // haproxy (apache?) gets upset and returns a 500. Let's try this. defer req.Body.Close() + defer io.Copy(ioutil.Discard, req.Body) if req.Method != "POST" && req.Method != "OPTIONS" { respond(405, w) @@ -150,7 +151,7 @@ func parseRequest(w http.ResponseWriter, req *http.Request, reportDir string) *p } if length > maxPayloadSize { log.Println("Content-length", length, "too large") - http.Error(w, fmt.Sprintf("Content too large (max %i)", maxPayloadSize), 413) + http.Error(w, fmt.Sprintf("Content too large (max %d)", maxPayloadSize), 413) return nil }