Commit bb4cf3f3 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http: on invalid request, send 400 response

Fixes #2160

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4930049
parent 4a4fa38d
......@@ -565,14 +565,18 @@ func (c *conn) serve() {
for {
w, err := c.readRequest()
if err != nil {
msg := "400 Bad Request"
if err == errTooLarge {
// Their HTTP client may or may not be
// able to read this if we're
// responding to them and hanging up
// while they're still writing their
// request. Undefined behavior.
fmt.Fprintf(c.rwc, "HTTP/1.1 400 Request Too Large\r\n\r\n")
msg = "400 Request Too Large"
} else if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
break // Don't reply
}
fmt.Fprintf(c.rwc, "HTTP/1.1 %s\r\n\r\n", msg)
break
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment