Skip to content

Commit b9ec002

Browse files
sethvargoadg
authored andcommitted
net/http: add missing HTTP status codes
This commit adds missing status codes: * 102 - Processing * 207 - Multi-Status * 208 - Already Reported * 226 - IM Used * 308 - Permanent Redirect * 422 - Unprocessable Entity * 423 - Locked * 424 - Failed Dependency * 426 - Upgrade Required * 506 - Variant Also Negotiates * 507 - Insufficient Storage * 508 - Loop Detected * 510 - Not Extended * 511 - Network Authentication Required Change-Id: Ife0e5b064f4b1e3542d2fd41abc9e7b1e410b644 Reviewed-on: https://go-review.googlesource.com/23090 Reviewed-by: Andrew Gerrand <[email protected]> Run-TryBot: Andrew Gerrand <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent a5d1a72 commit b9ec002

File tree

1 file changed

+75
-47
lines changed

1 file changed

+75
-47
lines changed

src/net/http/status.go

Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,79 @@
44

55
package http
66

7-
// HTTP status codes, defined in RFC 2616.
7+
// HTTP status codes as registered with IANA.
8+
// See: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
89
const (
9-
StatusContinue = 100
10-
StatusSwitchingProtocols = 101
10+
StatusContinue = 100 // RFC 7231, 6.2.1
11+
StatusSwitchingProtocols = 101 // RFC 7231, 6.2.2
12+
StatusProcessing = 102 // RFC 2518, 10.1
1113

12-
StatusOK = 200
13-
StatusCreated = 201
14-
StatusAccepted = 202
15-
StatusNonAuthoritativeInfo = 203
16-
StatusNoContent = 204
17-
StatusResetContent = 205
18-
StatusPartialContent = 206
14+
StatusOK = 200 // RFC 7231, 6.3.1
15+
StatusCreated = 201 // RFC 7231, 6.3.2
16+
StatusAccepted = 202 // RFC 7231, 6.3.3
17+
StatusNonAuthoritativeInfo = 203 // RFC 7231, 6.3.4
18+
StatusNoContent = 204 // RFC 7231, 6.3.5
19+
StatusResetContent = 205 // RFC 7231, 6.3.6
20+
StatusPartialContent = 206 // RFC 7233, 4.1
21+
StatusMultiStatus = 207 // RFC 4918, 11.1
22+
StatusAlreadyReported = 208 // RFC 5842, 7.1
23+
StatusIMUsed = 226 // RFC 3229, 10.4.1
1924

20-
StatusMultipleChoices = 300
21-
StatusMovedPermanently = 301
22-
StatusFound = 302
23-
StatusSeeOther = 303
24-
StatusNotModified = 304
25-
StatusUseProxy = 305
26-
StatusTemporaryRedirect = 307
25+
StatusMultipleChoices = 300 // RFC 7231, 6.4.1
26+
StatusMovedPermanently = 301 // RFC 7231, 6.4.2
27+
StatusFound = 302 // RFC 7231, 6.4.3
28+
StatusSeeOther = 303 // RFC 7231, 6.4.4
29+
StatusNotModified = 304 // RFC 7232, 4.1
30+
StatusUseProxy = 305 // RFC 7231, 6.4.5
31+
_ = 306 // RFC 7231, 6.4.6 (Unused)
32+
StatusTemporaryRedirect = 307 // RFC 7231, 6.4.7
33+
StatusPermanentRedirect = 308 // RFC 7538, 3
2734

28-
StatusBadRequest = 400
29-
StatusUnauthorized = 401
30-
StatusPaymentRequired = 402
31-
StatusForbidden = 403
32-
StatusNotFound = 404
33-
StatusMethodNotAllowed = 405
34-
StatusNotAcceptable = 406
35-
StatusProxyAuthRequired = 407
36-
StatusRequestTimeout = 408
37-
StatusConflict = 409
38-
StatusGone = 410
39-
StatusLengthRequired = 411
40-
StatusPreconditionFailed = 412
41-
StatusRequestEntityTooLarge = 413
42-
StatusRequestURITooLong = 414
43-
StatusUnsupportedMediaType = 415
44-
StatusRequestedRangeNotSatisfiable = 416
45-
StatusExpectationFailed = 417
46-
StatusTeapot = 418
47-
StatusPreconditionRequired = 428
48-
StatusTooManyRequests = 429
49-
StatusRequestHeaderFieldsTooLarge = 431
50-
StatusUnavailableForLegalReasons = 451
35+
StatusBadRequest = 400 // RFC 7231, 6.5.1
36+
StatusUnauthorized = 401 // RFC 7235, 3.1
37+
StatusPaymentRequired = 402 // RFC 7231, 6.5.2
38+
StatusForbidden = 403 // RFC 7231, 6.5.3
39+
StatusNotFound = 404 // RFC 7231, 6.5.4
40+
StatusMethodNotAllowed = 405 // RFC 7231, 6.5.5
41+
StatusNotAcceptable = 406 // RFC 7231, 6.5.6
42+
StatusProxyAuthRequired = 407 // RFC 7235, 3.2
43+
StatusRequestTimeout = 408 // RFC 7231, 6.5.7
44+
StatusConflict = 409 // RFC 7231, 6.5.8
45+
StatusGone = 410 // RFC 7231, 6.5.9
46+
StatusLengthRequired = 411 // RFC 7231, 6.5.10
47+
StatusPreconditionFailed = 412 // RFC 7232, 4.2
48+
StatusRequestEntityTooLarge = 413 // RFC 7231, 6.5.11
49+
StatusRequestURITooLong = 414 // RFC 7231, 6.5.12
50+
StatusUnsupportedMediaType = 415 // RFC 7231, 6.5.13
51+
StatusRequestedRangeNotSatisfiable = 416 // RFC 7233, 4.4
52+
StatusExpectationFailed = 417 // RFC 7231, 6.5.14
53+
StatusTeapot = 418 // RFC 7168, 2.3.3
54+
StatusUnprocessableEntity = 422 // RFC 4918, 11.2
55+
StatusLocked = 423 // RFC 4918, 11.3
56+
StatusFailedDependency = 424 // RFC 4918, 11.4
57+
StatusUpgradeRequired = 426 // RFC 7231, 6.5.15
58+
StatusPreconditionRequired = 428 // RFC 6585, 3
59+
StatusTooManyRequests = 429 // RFC 6585, 4
60+
StatusRequestHeaderFieldsTooLarge = 431 // RFC 6585, 5
61+
StatusUnavailableForLegalReasons = 451 // RFC 7725, 3
5162

52-
StatusInternalServerError = 500
53-
StatusNotImplemented = 501
54-
StatusBadGateway = 502
55-
StatusServiceUnavailable = 503
56-
StatusGatewayTimeout = 504
57-
StatusHTTPVersionNotSupported = 505
58-
StatusNetworkAuthenticationRequired = 511
63+
StatusInternalServerError = 500 // RFC 7231, 6.6.1
64+
StatusNotImplemented = 501 // RFC 7231, 6.6.2
65+
StatusBadGateway = 502 // RFC 7231, 6.6.3
66+
StatusServiceUnavailable = 503 // RFC 7231, 6.6.4
67+
StatusGatewayTimeout = 504 // RFC 7231, 6.6.5
68+
StatusHTTPVersionNotSupported = 505 // RFC 7231, 6.6.6
69+
StatusVariantAlsoNegotiates = 506 // RFC 2295, 8.1
70+
StatusInsufficientStorage = 507 // RFC 4918, 11.5
71+
StatusLoopDetected = 508 // RFC 5842, 7.2
72+
StatusNotExtended = 510 // RFC 2774, 7
73+
StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6
5974
)
6075

6176
var statusText = map[int]string{
6277
StatusContinue: "Continue",
6378
StatusSwitchingProtocols: "Switching Protocols",
79+
StatusProcessing: "Processing",
6480

6581
StatusOK: "OK",
6682
StatusCreated: "Created",
@@ -69,6 +85,9 @@ var statusText = map[int]string{
6985
StatusNoContent: "No Content",
7086
StatusResetContent: "Reset Content",
7187
StatusPartialContent: "Partial Content",
88+
StatusMultiStatus: "Multi-Status",
89+
StatusAlreadyReported: "Already Reported",
90+
StatusIMUsed: "IM Used",
7291

7392
StatusMultipleChoices: "Multiple Choices",
7493
StatusMovedPermanently: "Moved Permanently",
@@ -77,6 +96,7 @@ var statusText = map[int]string{
7796
StatusNotModified: "Not Modified",
7897
StatusUseProxy: "Use Proxy",
7998
StatusTemporaryRedirect: "Temporary Redirect",
99+
StatusPermanentRedirect: "Permanent Redirect",
80100

81101
StatusBadRequest: "Bad Request",
82102
StatusUnauthorized: "Unauthorized",
@@ -97,6 +117,10 @@ var statusText = map[int]string{
97117
StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable",
98118
StatusExpectationFailed: "Expectation Failed",
99119
StatusTeapot: "I'm a teapot",
120+
StatusUnprocessableEntity: "Unprocessable Entity",
121+
StatusLocked: "Locked",
122+
StatusFailedDependency: "Failed Dependency",
123+
StatusUpgradeRequired: "Upgrade Required",
100124
StatusPreconditionRequired: "Precondition Required",
101125
StatusTooManyRequests: "Too Many Requests",
102126
StatusRequestHeaderFieldsTooLarge: "Request Header Fields Too Large",
@@ -108,6 +132,10 @@ var statusText = map[int]string{
108132
StatusServiceUnavailable: "Service Unavailable",
109133
StatusGatewayTimeout: "Gateway Timeout",
110134
StatusHTTPVersionNotSupported: "HTTP Version Not Supported",
135+
StatusVariantAlsoNegotiates: "Variant Also Negotiates",
136+
StatusInsufficientStorage: "Insufficient Storage",
137+
StatusLoopDetected: "Loop Detected",
138+
StatusNotExtended: "Not Extended",
111139
StatusNetworkAuthenticationRequired: "Network Authentication Required",
112140
}
113141

0 commit comments

Comments
 (0)