]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: export the "new" error codes from RFC 6585
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 12 Oct 2015 20:41:40 +0000 (20:41 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 12 Oct 2015 22:35:31 +0000 (22:35 +0000)
These were proposed in the RFC over three years ago, then proposed to
be added to Go in https://codereview.appspot.com/7678043/ 2 years and
7 months ago, and the spec hasn't been updated or retracted the whole
time.

Time to export them.

Of note, HTTP/2 uses code 431 (Request Header Fields Too Large).

Updates #12843

Change-Id: I78c2fed5fab9540a98e845ace73f21c430a48809
Reviewed-on: https://go-review.googlesource.com/15732
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/status.go

index d253bd5cb54d49aacdb029a23f574b23a1de7b28..b071c5dc3e5281528a0bc5c438222a3a8f373dd4 100644 (file)
@@ -44,20 +44,17 @@ const (
        StatusRequestedRangeNotSatisfiable = 416
        StatusExpectationFailed            = 417
        StatusTeapot                       = 418
+       StatusPreconditionRequired         = 428
+       StatusTooManyRequests              = 429
+       StatusRequestHeaderFieldsTooLarge  = 431
 
-       StatusInternalServerError     = 500
-       StatusNotImplemented          = 501
-       StatusBadGateway              = 502
-       StatusServiceUnavailable      = 503
-       StatusGatewayTimeout          = 504
-       StatusHTTPVersionNotSupported = 505
-
-       // New HTTP status codes from RFC 6585. Not exported yet in Go 1.1.
-       // See discussion at https://codereview.appspot.com/7678043/
-       statusPreconditionRequired          = 428
-       statusTooManyRequests               = 429
-       statusRequestHeaderFieldsTooLarge   = 431
-       statusNetworkAuthenticationRequired = 511
+       StatusInternalServerError           = 500
+       StatusNotImplemented                = 501
+       StatusBadGateway                    = 502
+       StatusServiceUnavailable            = 503
+       StatusGatewayTimeout                = 504
+       StatusHTTPVersionNotSupported       = 505
+       StatusNetworkAuthenticationRequired = 511
 )
 
 var statusText = map[int]string{
@@ -99,18 +96,17 @@ var statusText = map[int]string{
        StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable",
        StatusExpectationFailed:            "Expectation Failed",
        StatusTeapot:                       "I'm a teapot",
+       StatusPreconditionRequired:         "Precondition Required",
+       StatusTooManyRequests:              "Too Many Requests",
+       StatusRequestHeaderFieldsTooLarge:  "Request Header Fields Too Large",
 
-       StatusInternalServerError:     "Internal Server Error",
-       StatusNotImplemented:          "Not Implemented",
-       StatusBadGateway:              "Bad Gateway",
-       StatusServiceUnavailable:      "Service Unavailable",
-       StatusGatewayTimeout:          "Gateway Timeout",
-       StatusHTTPVersionNotSupported: "HTTP Version Not Supported",
-
-       statusPreconditionRequired:          "Precondition Required",
-       statusTooManyRequests:               "Too Many Requests",
-       statusRequestHeaderFieldsTooLarge:   "Request Header Fields Too Large",
-       statusNetworkAuthenticationRequired: "Network Authentication Required",
+       StatusInternalServerError:           "Internal Server Error",
+       StatusNotImplemented:                "Not Implemented",
+       StatusBadGateway:                    "Bad Gateway",
+       StatusServiceUnavailable:            "Service Unavailable",
+       StatusGatewayTimeout:                "Gateway Timeout",
+       StatusHTTPVersionNotSupported:       "HTTP Version Not Supported",
+       StatusNetworkAuthenticationRequired: "Network Authentication Required",
 }
 
 // StatusText returns a text for the HTTP status code. It returns the empty