diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2011-08-24 13:10:22 +0400 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2011-08-24 13:10:22 +0400 |
| commit | bb4cf3f3514614e95b77918d3e15ff1b1f94397d (patch) | |
| tree | 9efef0b386f1196a3502841895364a2389af2287 /src/pkg/http | |
| parent | 4a4fa38d0e86064c6fec9e0fa9f60cb1782bcaff (diff) | |
| download | go-bb4cf3f3514614e95b77918d3e15ff1b1f94397d.tar.xz | |
http: on invalid request, send 400 response
Fixes #2160
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4930049
Diffstat (limited to 'src/pkg/http')
| -rw-r--r-- | src/pkg/http/server.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go index cf15b5f470..a6cb5eeafa 100644 --- a/src/pkg/http/server.go +++ b/src/pkg/http/server.go @@ -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 } |
