1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // HTTP status codes as registered with IANA.
8 // See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
10 StatusContinue
= 100 // RFC 7231, 6.2.1
11 StatusSwitchingProtocols
= 101 // RFC 7231, 6.2.2
12 StatusProcessing
= 102 // RFC 2518, 10.1
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
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
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 StatusMisdirectedRequest
= 421 // RFC 7540, 9.1.2
55 StatusUnprocessableEntity
= 422 // RFC 4918, 11.2
56 StatusLocked
= 423 // RFC 4918, 11.3
57 StatusFailedDependency
= 424 // RFC 4918, 11.4
58 StatusUpgradeRequired
= 426 // RFC 7231, 6.5.15
59 StatusPreconditionRequired
= 428 // RFC 6585, 3
60 StatusTooManyRequests
= 429 // RFC 6585, 4
61 StatusRequestHeaderFieldsTooLarge
= 431 // RFC 6585, 5
62 StatusUnavailableForLegalReasons
= 451 // RFC 7725, 3
64 StatusInternalServerError
= 500 // RFC 7231, 6.6.1
65 StatusNotImplemented
= 501 // RFC 7231, 6.6.2
66 StatusBadGateway
= 502 // RFC 7231, 6.6.3
67 StatusServiceUnavailable
= 503 // RFC 7231, 6.6.4
68 StatusGatewayTimeout
= 504 // RFC 7231, 6.6.5
69 StatusHTTPVersionNotSupported
= 505 // RFC 7231, 6.6.6
70 StatusVariantAlsoNegotiates
= 506 // RFC 2295, 8.1
71 StatusInsufficientStorage
= 507 // RFC 4918, 11.5
72 StatusLoopDetected
= 508 // RFC 5842, 7.2
73 StatusNotExtended
= 510 // RFC 2774, 7
74 StatusNetworkAuthenticationRequired
= 511 // RFC 6585, 6
77 var statusText
= map[int]string{
78 StatusContinue
: "Continue",
79 StatusSwitchingProtocols
: "Switching Protocols",
80 StatusProcessing
: "Processing",
83 StatusCreated
: "Created",
84 StatusAccepted
: "Accepted",
85 StatusNonAuthoritativeInfo
: "Non-Authoritative Information",
86 StatusNoContent
: "No Content",
87 StatusResetContent
: "Reset Content",
88 StatusPartialContent
: "Partial Content",
89 StatusMultiStatus
: "Multi-Status",
90 StatusAlreadyReported
: "Already Reported",
91 StatusIMUsed
: "IM Used",
93 StatusMultipleChoices
: "Multiple Choices",
94 StatusMovedPermanently
: "Moved Permanently",
96 StatusSeeOther
: "See Other",
97 StatusNotModified
: "Not Modified",
98 StatusUseProxy
: "Use Proxy",
99 StatusTemporaryRedirect
: "Temporary Redirect",
100 StatusPermanentRedirect
: "Permanent Redirect",
102 StatusBadRequest
: "Bad Request",
103 StatusUnauthorized
: "Unauthorized",
104 StatusPaymentRequired
: "Payment Required",
105 StatusForbidden
: "Forbidden",
106 StatusNotFound
: "Not Found",
107 StatusMethodNotAllowed
: "Method Not Allowed",
108 StatusNotAcceptable
: "Not Acceptable",
109 StatusProxyAuthRequired
: "Proxy Authentication Required",
110 StatusRequestTimeout
: "Request Timeout",
111 StatusConflict
: "Conflict",
113 StatusLengthRequired
: "Length Required",
114 StatusPreconditionFailed
: "Precondition Failed",
115 StatusRequestEntityTooLarge
: "Request Entity Too Large",
116 StatusRequestURITooLong
: "Request URI Too Long",
117 StatusUnsupportedMediaType
: "Unsupported Media Type",
118 StatusRequestedRangeNotSatisfiable
: "Requested Range Not Satisfiable",
119 StatusExpectationFailed
: "Expectation Failed",
120 StatusTeapot
: "I'm a teapot",
121 StatusMisdirectedRequest
: "Misdirected Request",
122 StatusUnprocessableEntity
: "Unprocessable Entity",
123 StatusLocked
: "Locked",
124 StatusFailedDependency
: "Failed Dependency",
125 StatusUpgradeRequired
: "Upgrade Required",
126 StatusPreconditionRequired
: "Precondition Required",
127 StatusTooManyRequests
: "Too Many Requests",
128 StatusRequestHeaderFieldsTooLarge
: "Request Header Fields Too Large",
129 StatusUnavailableForLegalReasons
: "Unavailable For Legal Reasons",
131 StatusInternalServerError
: "Internal Server Error",
132 StatusNotImplemented
: "Not Implemented",
133 StatusBadGateway
: "Bad Gateway",
134 StatusServiceUnavailable
: "Service Unavailable",
135 StatusGatewayTimeout
: "Gateway Timeout",
136 StatusHTTPVersionNotSupported
: "HTTP Version Not Supported",
137 StatusVariantAlsoNegotiates
: "Variant Also Negotiates",
138 StatusInsufficientStorage
: "Insufficient Storage",
139 StatusLoopDetected
: "Loop Detected",
140 StatusNotExtended
: "Not Extended",
141 StatusNetworkAuthenticationRequired
: "Network Authentication Required",
144 // StatusText returns a text for the HTTP status code. It returns the empty
145 // string if the code is unknown.
146 func StatusText(code
int) string {
147 return statusText
[code
]