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