github.com/google/go-safeweb@v0.0.0-20231219055052-64d8cfc90fbb/safehttp/status.go (about) 1 // Copyright 2020 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package safehttp 16 17 import "net/http" 18 19 // StatusCode contains HTTP status codes as registered with IANA. 20 // See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml 21 type StatusCode int 22 23 // The HTTP status codes registered with IANA. 24 const ( 25 StatusContinue StatusCode = 100 // RFC 7231, 6.2.1 26 StatusSwitchingProtocols StatusCode = 101 // RFC 7231, 6.2.2 27 StatusProcessing StatusCode = 102 // RFC 2518, 10.1 28 StatusEarlyHints StatusCode = 103 // RFC 8297 29 30 StatusOK StatusCode = 200 // RFC 7231, 6.3.1 31 StatusCreated StatusCode = 201 // RFC 7231, 6.3.2 32 StatusAccepted StatusCode = 202 // RFC 7231, 6.3.3 33 StatusNonAuthoritativeInfo StatusCode = 203 // RFC 7231, 6.3.4 34 StatusNoContent StatusCode = 204 // RFC 7231, 6.3.5 35 StatusResetContent StatusCode = 205 // RFC 7231, 6.3.6 36 StatusPartialContent StatusCode = 206 // RFC 7233, 4.1 37 StatusMultiStatus StatusCode = 207 // RFC 4918, 11.1 38 StatusAlreadyReported StatusCode = 208 // RFC 5842, 7.1 39 StatusIMUsed StatusCode = 226 // RFC 3229, 10.4.1 40 41 StatusMultipleChoice StatusCode = 300 // RFC 7231, 6.4.1 42 StatusMovedPermanently StatusCode = 301 // RFC 7231, 6.4.2 43 StatusFound StatusCode = 302 // RFC 7231, 6.4.3 44 StatusSeeOther StatusCode = 303 // RFC 7231, 6.4.4 45 StatusNotModified StatusCode = 304 // RFC 7232, 4.1 46 StatusUseProxy StatusCode = 305 // RFC 7231, 6.4.5 47 48 StatusTemporaryRedirect StatusCode = 307 // RFC 7231, 6.4.7 49 StatusPermanentRedirect StatusCode = 308 // RFC 7538, 3 50 51 StatusBadRequest StatusCode = 400 // RFC 7231, 6.5.1 52 StatusUnauthorized StatusCode = 401 // RFC 7235, 3.1 53 StatusPaymentRequired StatusCode = 402 // RFC 7231, 6.5.2 54 StatusForbidden StatusCode = 403 // RFC 7231, 6.5.3 55 StatusNotFound StatusCode = 404 // RFC 7231, 6.5.4 56 StatusMethodNotAllowed StatusCode = 405 // RFC 7231, 6.5.5 57 StatusNotAcceptable StatusCode = 406 // RFC 7231, 6.5.6 58 StatusProxyAuthRequired StatusCode = 407 // RFC 7235, 3.2 59 StatusRequestTimeout StatusCode = 408 // RFC 7231, 6.5.7 60 StatusConflict StatusCode = 409 // RFC 7231, 6.5.8 61 StatusGone StatusCode = 410 // RFC 7231, 6.5.9 62 StatusLengthRequired StatusCode = 411 // RFC 7231, 6.5.10 63 StatusPreconditionFailed StatusCode = 412 // RFC 7232, 4.2 64 StatusRequestEntityTooLarge StatusCode = 413 // RFC 7231, 6.5.11 65 StatusRequestURITooLong StatusCode = 414 // RFC 7231, 6.5.12 66 StatusUnsupportedMediaType StatusCode = 415 // RFC 7231, 6.5.13 67 StatusRequestedRangeNotSatisfiable StatusCode = 416 // RFC 7233, 4.4 68 StatusExpectationFailed StatusCode = 417 // RFC 7231, 6.5.14 69 StatusTeapot StatusCode = 418 // RFC 7168, 2.3.3 70 StatusMisdirectedRequest StatusCode = 421 // RFC 7540, 9.1.2 71 StatusUnprocessableEntity StatusCode = 422 // RFC 4918, 11.2 72 StatusLocked StatusCode = 423 // RFC 4918, 11.3 73 StatusFailedDependency StatusCode = 424 // RFC 4918, 11.4 74 StatusTooEarly StatusCode = 425 // RFC 8470, 5.2. 75 StatusUpgradeRequired StatusCode = 426 // RFC 7231, 6.5.15 76 StatusPreconditionRequired StatusCode = 428 // RFC 6585, 3 77 StatusTooManyRequests StatusCode = 429 // RFC 6585, 4 78 StatusRequestHeaderFieldsTooLarg StatusCode = 431 // RFC 6585, 5 79 StatusUnavailableForLegalReasons StatusCode = 451 // RFC 7725, 3 80 81 StatusInternalServerError StatusCode = 500 // RFC 7231, 6.6.1 82 StatusNotImplemented StatusCode = 501 // RFC 7231, 6.6.2 83 StatusBadGateway StatusCode = 502 // RFC 7231, 6.6.3 84 StatusServiceUnavailable StatusCode = 503 // RFC 7231, 6.6.4 85 StatusGatewayTimeout StatusCode = 504 // RFC 7231, 6.6.5 86 StatusHTTPVersionNotSupported StatusCode = 505 // RFC 7231, 6.6.6 87 StatusVariantAlsoNegotiates StatusCode = 506 // RFC 2295, 8.1 88 StatusInsufficientStorage StatusCode = 507 // RFC 4918, 11.5 89 StatusLoopDetected StatusCode = 508 // RFC 5842, 7.2 90 StatusNotExtended StatusCode = 510 // RFC 2774, 7 91 StatusNetworkAuthenticationRequired StatusCode = 511 // RFC 6585, 6 92 ) 93 94 // Code implements ErrorResponse. 95 func (c StatusCode) Code() StatusCode { 96 return c 97 } 98 99 func (c StatusCode) String() string { 100 return http.StatusText(int(c)) 101 }