github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/pkg/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, 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 // New HTTP status codes from RFC 6585. Not exported yet in Go 1.1. 56 // See discussion at https://codereview.appspot.com/7678043/ 57 statusPreconditionRequired = 428 58 statusTooManyRequests = 429 59 statusRequestHeaderFieldsTooLarge = 431 60 statusNetworkAuthenticationRequired = 511 61 ) 62 63 var statusText = map[int]string{ 64 StatusContinue: "Continue", 65 StatusSwitchingProtocols: "Switching Protocols", 66 67 StatusOK: "OK", 68 StatusCreated: "Created", 69 StatusAccepted: "Accepted", 70 StatusNonAuthoritativeInfo: "Non-Authoritative Information", 71 StatusNoContent: "No Content", 72 StatusResetContent: "Reset Content", 73 StatusPartialContent: "Partial Content", 74 75 StatusMultipleChoices: "Multiple Choices", 76 StatusMovedPermanently: "Moved Permanently", 77 StatusFound: "Found", 78 StatusSeeOther: "See Other", 79 StatusNotModified: "Not Modified", 80 StatusUseProxy: "Use Proxy", 81 StatusTemporaryRedirect: "Temporary Redirect", 82 83 StatusBadRequest: "Bad Request", 84 StatusUnauthorized: "Unauthorized", 85 StatusPaymentRequired: "Payment Required", 86 StatusForbidden: "Forbidden", 87 StatusNotFound: "Not Found", 88 StatusMethodNotAllowed: "Method Not Allowed", 89 StatusNotAcceptable: "Not Acceptable", 90 StatusProxyAuthRequired: "Proxy Authentication Required", 91 StatusRequestTimeout: "Request Timeout", 92 StatusConflict: "Conflict", 93 StatusGone: "Gone", 94 StatusLengthRequired: "Length Required", 95 StatusPreconditionFailed: "Precondition Failed", 96 StatusRequestEntityTooLarge: "Request Entity Too Large", 97 StatusRequestURITooLong: "Request URI Too Long", 98 StatusUnsupportedMediaType: "Unsupported Media Type", 99 StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable", 100 StatusExpectationFailed: "Expectation Failed", 101 StatusTeapot: "I'm a teapot", 102 103 StatusInternalServerError: "Internal Server Error", 104 StatusNotImplemented: "Not Implemented", 105 StatusBadGateway: "Bad Gateway", 106 StatusServiceUnavailable: "Service Unavailable", 107 StatusGatewayTimeout: "Gateway Timeout", 108 StatusHTTPVersionNotSupported: "HTTP Version Not Supported", 109 110 statusPreconditionRequired: "Precondition Required", 111 statusTooManyRequests: "Too Many Requests", 112 statusRequestHeaderFieldsTooLarge: "Request Header Fields Too Large", 113 statusNetworkAuthenticationRequired: "Network Authentication Required", 114 } 115 116 // StatusText returns a text for the HTTP status code. It returns the empty 117 // string if the code is unknown. 118 func StatusText(code int) string { 119 return statusText[code] 120 }