From: Dave Cheney Date: Thu, 25 Aug 2011 10:00:00 +0000 (+0400) Subject: http: return 413 instead of 400 when the request body is too large X-Git-Tag: weekly.2011-09-01~88 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8511ed454a40f861e1b2aac6acbe6d6aa8325bf3;p=gostls13.git 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 --- diff --git a/src/pkg/http/serve_test.go b/src/pkg/http/serve_test.go index 08925faa0e..17439110f0 100644 --- a/src/pkg/http/serve_test.go +++ b/src/pkg/http/serve_test.go @@ -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) } } diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go index a6cb5eeafa..654af378a1 100644 --- a/src/pkg/http/server.go +++ b/src/pkg/http/server.go @@ -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 }