...
Run Format

Source file src/net/http/status.go

     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: http://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	
    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		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
    62	
    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
    74	)
    75	
    76	var statusText = map[int]string{
    77		StatusContinue:           "Continue",
    78		StatusSwitchingProtocols: "Switching Protocols",
    79		StatusProcessing:         "Processing",
    80	
    81		StatusOK:                   "OK",
    82		StatusCreated:              "Created",
    83		StatusAccepted:             "Accepted",
    84		StatusNonAuthoritativeInfo: "Non-Authoritative Information",
    85		StatusNoContent:            "No Content",
    86		StatusResetContent:         "Reset Content",
    87		StatusPartialContent:       "Partial Content",
    88		StatusMultiStatus:          "Multi-Status",
    89		StatusAlreadyReported:      "Already Reported",
    90		StatusIMUsed:               "IM Used",
    91	
    92		StatusMultipleChoices:   "Multiple Choices",
    93		StatusMovedPermanently:  "Moved Permanently",
    94		StatusFound:             "Found",
    95		StatusSeeOther:          "See Other",
    96		StatusNotModified:       "Not Modified",
    97		StatusUseProxy:          "Use Proxy",
    98		StatusTemporaryRedirect: "Temporary Redirect",
    99		StatusPermanentRedirect: "Permanent Redirect",
   100	
   101		StatusBadRequest:                   "Bad Request",
   102		StatusUnauthorized:                 "Unauthorized",
   103		StatusPaymentRequired:              "Payment Required",
   104		StatusForbidden:                    "Forbidden",
   105		StatusNotFound:                     "Not Found",
   106		StatusMethodNotAllowed:             "Method Not Allowed",
   107		StatusNotAcceptable:                "Not Acceptable",
   108		StatusProxyAuthRequired:            "Proxy Authentication Required",
   109		StatusRequestTimeout:               "Request Timeout",
   110		StatusConflict:                     "Conflict",
   111		StatusGone:                         "Gone",
   112		StatusLengthRequired:               "Length Required",
   113		StatusPreconditionFailed:           "Precondition Failed",
   114		StatusRequestEntityTooLarge:        "Request Entity Too Large",
   115		StatusRequestURITooLong:            "Request URI Too Long",
   116		StatusUnsupportedMediaType:         "Unsupported Media Type",
   117		StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable",
   118		StatusExpectationFailed:            "Expectation Failed",
   119		StatusTeapot:                       "I'm a teapot",
   120		StatusUnprocessableEntity:          "Unprocessable Entity",
   121		StatusLocked:                       "Locked",
   122		StatusFailedDependency:             "Failed Dependency",
   123		StatusUpgradeRequired:              "Upgrade Required",
   124		StatusPreconditionRequired:         "Precondition Required",
   125		StatusTooManyRequests:              "Too Many Requests",
   126		StatusRequestHeaderFieldsTooLarge:  "Request Header Fields Too Large",
   127		StatusUnavailableForLegalReasons:   "Unavailable For Legal Reasons",
   128	
   129		StatusInternalServerError:           "Internal Server Error",
   130		StatusNotImplemented:                "Not Implemented",
   131		StatusBadGateway:                    "Bad Gateway",
   132		StatusServiceUnavailable:            "Service Unavailable",
   133		StatusGatewayTimeout:                "Gateway Timeout",
   134		StatusHTTPVersionNotSupported:       "HTTP Version Not Supported",
   135		StatusVariantAlsoNegotiates:         "Variant Also Negotiates",
   136		StatusInsufficientStorage:           "Insufficient Storage",
   137		StatusLoopDetected:                  "Loop Detected",
   138		StatusNotExtended:                   "Not Extended",
   139		StatusNetworkAuthenticationRequired: "Network Authentication Required",
   140	}
   141	
   142	// StatusText returns a text for the HTTP status code. It returns the empty
   143	// string if the code is unknown.
   144	func StatusText(code int) string {
   145		return statusText[code]
   146	}
   147	

View as plain text