github.com/guyezi/gofrontend@v0.0.0-20200228202240-7a62a49e62c0/libgo/go/net/http/status.go (about)

     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  
     5  package http
     6  
     7  // HTTP status codes as registered with IANA.
     8  // See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
     9  const (
    10  	StatusContinue           = 100 // RFC 7231, 6.2.1
    11  	StatusSwitchingProtocols = 101 // RFC 7231, 6.2.2
    12  	StatusProcessing         = 102 // RFC 2518, 10.1
    13  	StatusEarlyHints         = 103 // RFC 8297
    14  
    15  	StatusOK                   = 200 // RFC 7231, 6.3.1
    16  	StatusCreated              = 201 // RFC 7231, 6.3.2
    17  	StatusAccepted             = 202 // RFC 7231, 6.3.3
    18  	StatusNonAuthoritativeInfo = 203 // RFC 7231, 6.3.4
    19  	StatusNoContent            = 204 // RFC 7231, 6.3.5
    20  	StatusResetContent         = 205 // RFC 7231, 6.3.6
    21  	StatusPartialContent       = 206 // RFC 7233, 4.1
    22  	StatusMultiStatus          = 207 // RFC 4918, 11.1
    23  	StatusAlreadyReported      = 208 // RFC 5842, 7.1
    24  	StatusIMUsed               = 226 // RFC 3229, 10.4.1
    25  
    26  	StatusMultipleChoices   = 300 // RFC 7231, 6.4.1
    27  	StatusMovedPermanently  = 301 // RFC 7231, 6.4.2
    28  	StatusFound             = 302 // RFC 7231, 6.4.3
    29  	StatusSeeOther          = 303 // RFC 7231, 6.4.4
    30  	StatusNotModified       = 304 // RFC 7232, 4.1
    31  	StatusUseProxy          = 305 // RFC 7231, 6.4.5
    32  	_                       = 306 // RFC 7231, 6.4.6 (Unused)
    33  	StatusTemporaryRedirect = 307 // RFC 7231, 6.4.7
    34  	StatusPermanentRedirect = 308 // RFC 7538, 3
    35  
    36  	StatusBadRequest                   = 400 // RFC 7231, 6.5.1
    37  	StatusUnauthorized                 = 401 // RFC 7235, 3.1
    38  	StatusPaymentRequired              = 402 // RFC 7231, 6.5.2
    39  	StatusForbidden                    = 403 // RFC 7231, 6.5.3
    40  	StatusNotFound                     = 404 // RFC 7231, 6.5.4
    41  	StatusMethodNotAllowed             = 405 // RFC 7231, 6.5.5
    42  	StatusNotAcceptable                = 406 // RFC 7231, 6.5.6
    43  	StatusProxyAuthRequired            = 407 // RFC 7235, 3.2
    44  	StatusRequestTimeout               = 408 // RFC 7231, 6.5.7
    45  	StatusConflict                     = 409 // RFC 7231, 6.5.8
    46  	StatusGone                         = 410 // RFC 7231, 6.5.9
    47  	StatusLengthRequired               = 411 // RFC 7231, 6.5.10
    48  	StatusPreconditionFailed           = 412 // RFC 7232, 4.2
    49  	StatusRequestEntityTooLarge        = 413 // RFC 7231, 6.5.11
    50  	StatusRequestURITooLong            = 414 // RFC 7231, 6.5.12
    51  	StatusUnsupportedMediaType         = 415 // RFC 7231, 6.5.13
    52  	StatusRequestedRangeNotSatisfiable = 416 // RFC 7233, 4.4
    53  	StatusExpectationFailed            = 417 // RFC 7231, 6.5.14
    54  	StatusTeapot                       = 418 // RFC 7168, 2.3.3
    55  	StatusMisdirectedRequest           = 421 // RFC 7540, 9.1.2
    56  	StatusUnprocessableEntity          = 422 // RFC 4918, 11.2
    57  	StatusLocked                       = 423 // RFC 4918, 11.3
    58  	StatusFailedDependency             = 424 // RFC 4918, 11.4
    59  	StatusTooEarly                     = 425 // RFC 8470, 5.2.
    60  	StatusUpgradeRequired              = 426 // RFC 7231, 6.5.15
    61  	StatusPreconditionRequired         = 428 // RFC 6585, 3
    62  	StatusTooManyRequests              = 429 // RFC 6585, 4
    63  	StatusRequestHeaderFieldsTooLarge  = 431 // RFC 6585, 5
    64  	StatusUnavailableForLegalReasons   = 451 // RFC 7725, 3
    65  
    66  	StatusInternalServerError           = 500 // RFC 7231, 6.6.1
    67  	StatusNotImplemented                = 501 // RFC 7231, 6.6.2
    68  	StatusBadGateway                    = 502 // RFC 7231, 6.6.3
    69  	StatusServiceUnavailable            = 503 // RFC 7231, 6.6.4
    70  	StatusGatewayTimeout                = 504 // RFC 7231, 6.6.5
    71  	StatusHTTPVersionNotSupported       = 505 // RFC 7231, 6.6.6
    72  	StatusVariantAlsoNegotiates         = 506 // RFC 2295, 8.1
    73  	StatusInsufficientStorage           = 507 // RFC 4918, 11.5
    74  	StatusLoopDetected                  = 508 // RFC 5842, 7.2
    75  	StatusNotExtended                   = 510 // RFC 2774, 7
    76  	StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6
    77  )
    78  
    79  var statusText = map[int]string{
    80  	StatusContinue:           "Continue",
    81  	StatusSwitchingProtocols: "Switching Protocols",
    82  	StatusProcessing:         "Processing",
    83  	StatusEarlyHints:         "Early Hints",
    84  
    85  	StatusOK:                   "OK",
    86  	StatusCreated:              "Created",
    87  	StatusAccepted:             "Accepted",
    88  	StatusNonAuthoritativeInfo: "Non-Authoritative Information",
    89  	StatusNoContent:            "No Content",
    90  	StatusResetContent:         "Reset Content",
    91  	StatusPartialContent:       "Partial Content",
    92  	StatusMultiStatus:          "Multi-Status",
    93  	StatusAlreadyReported:      "Already Reported",
    94  	StatusIMUsed:               "IM Used",
    95  
    96  	StatusMultipleChoices:   "Multiple Choices",
    97  	StatusMovedPermanently:  "Moved Permanently",
    98  	StatusFound:             "Found",
    99  	StatusSeeOther:          "See Other",
   100  	StatusNotModified:       "Not Modified",
   101  	StatusUseProxy:          "Use Proxy",
   102  	StatusTemporaryRedirect: "Temporary Redirect",
   103  	StatusPermanentRedirect: "Permanent Redirect",
   104  
   105  	StatusBadRequest:                   "Bad Request",
   106  	StatusUnauthorized:                 "Unauthorized",
   107  	StatusPaymentRequired:              "Payment Required",
   108  	StatusForbidden:                    "Forbidden",
   109  	StatusNotFound:                     "Not Found",
   110  	StatusMethodNotAllowed:             "Method Not Allowed",
   111  	StatusNotAcceptable:                "Not Acceptable",
   112  	StatusProxyAuthRequired:            "Proxy Authentication Required",
   113  	StatusRequestTimeout:               "Request Timeout",
   114  	StatusConflict:                     "Conflict",
   115  	StatusGone:                         "Gone",
   116  	StatusLengthRequired:               "Length Required",
   117  	StatusPreconditionFailed:           "Precondition Failed",
   118  	StatusRequestEntityTooLarge:        "Request Entity Too Large",
   119  	StatusRequestURITooLong:            "Request URI Too Long",
   120  	StatusUnsupportedMediaType:         "Unsupported Media Type",
   121  	StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable",
   122  	StatusExpectationFailed:            "Expectation Failed",
   123  	StatusTeapot:                       "I'm a teapot",
   124  	StatusMisdirectedRequest:           "Misdirected Request",
   125  	StatusUnprocessableEntity:          "Unprocessable Entity",
   126  	StatusLocked:                       "Locked",
   127  	StatusFailedDependency:             "Failed Dependency",
   128  	StatusTooEarly:                     "Too Early",
   129  	StatusUpgradeRequired:              "Upgrade Required",
   130  	StatusPreconditionRequired:         "Precondition Required",
   131  	StatusTooManyRequests:              "Too Many Requests",
   132  	StatusRequestHeaderFieldsTooLarge:  "Request Header Fields Too Large",
   133  	StatusUnavailableForLegalReasons:   "Unavailable For Legal Reasons",
   134  
   135  	StatusInternalServerError:           "Internal Server Error",
   136  	StatusNotImplemented:                "Not Implemented",
   137  	StatusBadGateway:                    "Bad Gateway",
   138  	StatusServiceUnavailable:            "Service Unavailable",
   139  	StatusGatewayTimeout:                "Gateway Timeout",
   140  	StatusHTTPVersionNotSupported:       "HTTP Version Not Supported",
   141  	StatusVariantAlsoNegotiates:         "Variant Also Negotiates",
   142  	StatusInsufficientStorage:           "Insufficient Storage",
   143  	StatusLoopDetected:                  "Loop Detected",
   144  	StatusNotExtended:                   "Not Extended",
   145  	StatusNetworkAuthenticationRequired: "Network Authentication Required",
   146  }
   147  
   148  // StatusText returns a text for the HTTP status code. It returns the empty
   149  // string if the code is unknown.
   150  func StatusText(code int) string {
   151  	return statusText[code]
   152  }