src/pkg/net/http/status.go - The Go Programming Language

Golang

Source file src/pkg/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, defined in RFC 2616.
     8	const (
     9		StatusContinue           = 100
    10		StatusSwitchingProtocols = 101
    11	
    12		StatusOK                   = 200
    13		StatusCreated              = 201
    14		StatusAccepted             = 202
    15		StatusNonAuthoritativeInfo = 203
    16		StatusNoContent            = 204
    17		StatusResetContent         = 205
    18		StatusPartialContent       = 206
    19	
    20		StatusMultipleChoices   = 300
    21		StatusMovedPermanently  = 301
    22		StatusFound             = 302
    23		StatusSeeOther          = 303
    24		StatusNotModified       = 304
    25		StatusUseProxy          = 305
    26		StatusTemporaryRedirect = 307
    27	
    28		StatusBadRequest                   = 400
    29		StatusUnauthorized                 = 401
    30		StatusPaymentRequired              = 402
    31		StatusForbidden                    = 403
    32		StatusNotFound                     = 404
    33		StatusMethodNotAllowed             = 405
    34		StatusNotAcceptable                = 406
    35		StatusProxyAuthRequired            = 407
    36		StatusRequestTimeout               = 408
    37		StatusConflict                     = 409
    38		StatusGone                         = 410
    39		StatusLengthRequired               = 411
    40		StatusPreconditionFailed           = 412
    41		StatusRequestEntityTooLarge        = 413
    42		StatusRequestURITooLong            = 414
    43		StatusUnsupportedMediaType         = 415
    44		StatusRequestedRangeNotSatisfiable = 416
    45		StatusExpectationFailed            = 417
    46		StatusTeapot                       = 418
    47	
    48		StatusInternalServerError     = 500
    49		StatusNotImplemented          = 501
    50		StatusBadGateway              = 502
    51		StatusServiceUnavailable      = 503
    52		StatusGatewayTimeout          = 504
    53		StatusHTTPVersionNotSupported = 505
    54	)
    55	
    56	var statusText = map[int]string{
    57		StatusContinue:           "Continue",
    58		StatusSwitchingProtocols: "Switching Protocols",
    59	
    60		StatusOK:                   "OK",
    61		StatusCreated:              "Created",
    62		StatusAccepted:             "Accepted",
    63		StatusNonAuthoritativeInfo: "Non-Authoritative Information",
    64		StatusNoContent:            "No Content",
    65		StatusResetContent:         "Reset Content",
    66		StatusPartialContent:       "Partial Content",
    67	
    68		StatusMultipleChoices:   "Multiple Choices",
    69		StatusMovedPermanently:  "Moved Permanently",
    70		StatusFound:             "Found",
    71		StatusSeeOther:          "See Other",
    72		StatusNotModified:       "Not Modified",
    73		StatusUseProxy:          "Use Proxy",
    74		StatusTemporaryRedirect: "Temporary Redirect",
    75	
    76		StatusBadRequest:                   "Bad Request",
    77		StatusUnauthorized:                 "Unauthorized",
    78		StatusPaymentRequired:              "Payment Required",
    79		StatusForbidden:                    "Forbidden",
    80		StatusNotFound:                     "Not Found",
    81		StatusMethodNotAllowed:             "Method Not Allowed",
    82		StatusNotAcceptable:                "Not Acceptable",
    83		StatusProxyAuthRequired:            "Proxy Authentication Required",
    84		StatusRequestTimeout:               "Request Timeout",
    85		StatusConflict:                     "Conflict",
    86		StatusGone:                         "Gone",
    87		StatusLengthRequired:               "Length Required",
    88		StatusPreconditionFailed:           "Precondition Failed",
    89		StatusRequestEntityTooLarge:        "Request Entity Too Large",
    90		StatusRequestURITooLong:            "Request URI Too Long",
    91		StatusUnsupportedMediaType:         "Unsupported Media Type",
    92		StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable",
    93		StatusExpectationFailed:            "Expectation Failed",
    94		StatusTeapot:                       "I'm a teapot",
    95	
    96		StatusInternalServerError:     "Internal Server Error",
    97		StatusNotImplemented:          "Not Implemented",
    98		StatusBadGateway:              "Bad Gateway",
    99		StatusServiceUnavailable:      "Service Unavailable",
   100		StatusGatewayTimeout:          "Gateway Timeout",
   101		StatusHTTPVersionNotSupported: "HTTP Version Not Supported",
   102	}
   103	
   104	// StatusText returns a text for the HTTP status code. It returns the empty
   105	// string if the code is unknown.
   106	func StatusText(code int) string {
   107		return statusText[code]
   108	}