Skip to content

Commit

Permalink
Read request body before sending response
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Mar 6, 2018
1 parent 00b9337 commit e88a448
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/github.com/matrix-org/rageshake/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit e88a448

Please sign in to comment.