| 1 |
747 |
jeremybenn |
// 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 |
|
|
|
| 47 |
|
|
StatusInternalServerError = 500
|
| 48 |
|
|
StatusNotImplemented = 501
|
| 49 |
|
|
StatusBadGateway = 502
|
| 50 |
|
|
StatusServiceUnavailable = 503
|
| 51 |
|
|
StatusGatewayTimeout = 504
|
| 52 |
|
|
StatusHTTPVersionNotSupported = 505
|
| 53 |
|
|
)
|
| 54 |
|
|
|
| 55 |
|
|
var statusText = map[int]string{
|
| 56 |
|
|
StatusContinue: "Continue",
|
| 57 |
|
|
StatusSwitchingProtocols: "Switching Protocols",
|
| 58 |
|
|
|
| 59 |
|
|
StatusOK: "OK",
|
| 60 |
|
|
StatusCreated: "Created",
|
| 61 |
|
|
StatusAccepted: "Accepted",
|
| 62 |
|
|
StatusNonAuthoritativeInfo: "Non-Authoritative Information",
|
| 63 |
|
|
StatusNoContent: "No Content",
|
| 64 |
|
|
StatusResetContent: "Reset Content",
|
| 65 |
|
|
StatusPartialContent: "Partial Content",
|
| 66 |
|
|
|
| 67 |
|
|
StatusMultipleChoices: "Multiple Choices",
|
| 68 |
|
|
StatusMovedPermanently: "Moved Permanently",
|
| 69 |
|
|
StatusFound: "Found",
|
| 70 |
|
|
StatusSeeOther: "See Other",
|
| 71 |
|
|
StatusNotModified: "Not Modified",
|
| 72 |
|
|
StatusUseProxy: "Use Proxy",
|
| 73 |
|
|
StatusTemporaryRedirect: "Temporary Redirect",
|
| 74 |
|
|
|
| 75 |
|
|
StatusBadRequest: "Bad Request",
|
| 76 |
|
|
StatusUnauthorized: "Unauthorized",
|
| 77 |
|
|
StatusPaymentRequired: "Payment Required",
|
| 78 |
|
|
StatusForbidden: "Forbidden",
|
| 79 |
|
|
StatusNotFound: "Not Found",
|
| 80 |
|
|
StatusMethodNotAllowed: "Method Not Allowed",
|
| 81 |
|
|
StatusNotAcceptable: "Not Acceptable",
|
| 82 |
|
|
StatusProxyAuthRequired: "Proxy Authentication Required",
|
| 83 |
|
|
StatusRequestTimeout: "Request Timeout",
|
| 84 |
|
|
StatusConflict: "Conflict",
|
| 85 |
|
|
StatusGone: "Gone",
|
| 86 |
|
|
StatusLengthRequired: "Length Required",
|
| 87 |
|
|
StatusPreconditionFailed: "Precondition Failed",
|
| 88 |
|
|
StatusRequestEntityTooLarge: "Request Entity Too Large",
|
| 89 |
|
|
StatusRequestURITooLong: "Request URI Too Long",
|
| 90 |
|
|
StatusUnsupportedMediaType: "Unsupported Media Type",
|
| 91 |
|
|
StatusRequestedRangeNotSatisfiable: "Requested Range Not Satisfiable",
|
| 92 |
|
|
StatusExpectationFailed: "Expectation Failed",
|
| 93 |
|
|
|
| 94 |
|
|
StatusInternalServerError: "Internal Server Error",
|
| 95 |
|
|
StatusNotImplemented: "Not Implemented",
|
| 96 |
|
|
StatusBadGateway: "Bad Gateway",
|
| 97 |
|
|
StatusServiceUnavailable: "Service Unavailable",
|
| 98 |
|
|
StatusGatewayTimeout: "Gateway Timeout",
|
| 99 |
|
|
StatusHTTPVersionNotSupported: "HTTP Version Not Supported",
|
| 100 |
|
|
}
|
| 101 |
|
|
|
| 102 |
|
|
// StatusText returns a text for the HTTP status code. It returns the empty
|
| 103 |
|
|
// string if the code is unknown.
|
| 104 |
|
|
func StatusText(code int) string {
|
| 105 |
|
|
return statusText[code]
|
| 106 |
|
|
}
|