]> Cypherpunks repositories - gostls13.git/commitdiff
http: return 413 instead of 400 when the request body is too large
authorDave Cheney <dave@cheney.net>
Thu, 25 Aug 2011 10:00:00 +0000 (14:00 +0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 25 Aug 2011 10:00:00 +0000 (14:00 +0400)
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

src/pkg/http/serve_test.go
src/pkg/http/server.go

index 08925faa0e1bd118279dfdd382e10bb6da630f7c..17439110f06a745cbf7339d4ad5fc66eda83ce6c 100644 (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)
        }
 }
 
index a6cb5eeafaa8d198b378cf278f8302b5d6c41979..654af378a1b3573348bf336fdc3ff7028df7772c 100644 (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
                        }