Read request body before sending response
This commit is contained in:
parent
00b9337e01
commit
e88a448a20
1 changed files with 3 additions and 2 deletions
|
@ -85,8 +85,9 @@ type submitResponse struct {
|
||||||
|
|
||||||
func (s *submitServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (s *submitServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
// if we attempt to return a response without reading the request body,
|
// 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 req.Body.Close()
|
||||||
|
defer io.Copy(ioutil.Discard, req.Body)
|
||||||
|
|
||||||
if req.Method != "POST" && req.Method != "OPTIONS" {
|
if req.Method != "POST" && req.Method != "OPTIONS" {
|
||||||
respond(405, w)
|
respond(405, w)
|
||||||
|
@ -150,7 +151,7 @@ func parseRequest(w http.ResponseWriter, req *http.Request, reportDir string) *p
|
||||||
}
|
}
|
||||||
if length > maxPayloadSize {
|
if length > maxPayloadSize {
|
||||||
log.Println("Content-length", length, "too large")
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue