From: Brad Fitzpatrick Date: Mon, 12 Oct 2015 20:41:40 +0000 (+0000) Subject: net/http: export the "new" error codes from RFC 6585 X-Git-Tag: go1.6beta1~856 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8dd52cf03a37a8fe0d0db20000036db8ee8cd3d2;p=gostls13.git net/http: export the "new" error codes from RFC 6585 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 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/net/http/status.go b/src/net/http/status.go index d253bd5cb5..b071c5dc3e 100644 --- a/src/net/http/status.go +++ b/src/net/http/status.go @@ -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