http: return 413 instead of 400 when the request body is too large

RFC2616 says servers should return this status code when
rejecting requests that are too large.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.14

R=bradfitz
CC=golang-dev
https://golang.org/cl/4962041
This commit is contained in:
Dave Cheney 2011-08-25 14:00:00 +04:00 committed by Brad Fitzpatrick
parent 1f0d277cc1
commit 8511ed454a
2 changed files with 3 additions and 3 deletions

View File

@ -891,8 +891,8 @@ func TestRequestLimit(t *testing.T) {
// we do support it (at least currently), so we expect a response below.
t.Fatalf("Do: %v", err)
}
if res.StatusCode != 400 {
t.Fatalf("expected 400 response status; got: %d %s", res.StatusCode, res.Status)
if res.StatusCode != 413 {
t.Fatalf("expected 413 response status; got: %d %s", res.StatusCode, res.Status)
}
}

View File

@ -572,7 +572,7 @@ func (c *conn) serve() {
// responding to them and hanging up
// while they're still writing their
// request. Undefined behavior.
msg = "400 Request Too Large"
msg = "413 Request Entity Too Large"
} else if neterr, ok := err.(net.Error); ok && neterr.Timeout() {
break // Don't reply
}