4977c794911f4048a17cfa86db0344e35fc3fdfd
1 module ActionController
2 module StatusCodes
#:nodoc:
3 # Defines the standard HTTP status codes, by integer, with their
4 # corresponding default message texts.
5 # Source: http://www.iana.org/assignments/http-status-codes
8 101 => "Switching Protocols",
14 203 => "Non-Authoritative Information",
16 205 => "Reset Content",
17 206 => "Partial Content",
18 207 => "Multi-Status",
21 300 => "Multiple Choices",
22 301 => "Moved Permanently",
25 304 => "Not Modified",
27 307 => "Temporary Redirect",
30 401 => "Unauthorized",
31 402 => "Payment Required",
34 405 => "Method Not Allowed",
35 406 => "Not Acceptable",
36 407 => "Proxy Authentication Required",
37 408 => "Request Timeout",
40 411 => "Length Required",
41 412 => "Precondition Failed",
42 413 => "Request Entity Too Large",
43 414 => "Request-URI Too Long",
44 415 => "Unsupported Media Type",
45 416 => "Requested Range Not Satisfiable",
46 417 => "Expectation Failed",
47 422 => "Unprocessable Entity",
49 424 => "Failed Dependency",
50 426 => "Upgrade Required",
52 500 => "Internal Server Error",
53 501 => "Not Implemented",
55 503 => "Service Unavailable",
56 504 => "Gateway Timeout",
57 505 => "HTTP Version Not Supported",
58 507 => "Insufficient Storage",
62 # Provides a symbol-to-fixnum lookup for converting a symbol (like
63 # :created or :not_implemented) into its corresponding HTTP status
64 # code (like 200 or 501).
65 SYMBOL_TO_STATUS_CODE
= STATUS_CODES
.inject({}) do |hash
, (code
, message
)|
66 hash
[message
.gsub(/ /, "").underscore
.to_sym
] = code
70 # Given a status parameter, determine whether it needs to be converted
71 # to a string. If it is a fixnum, use the STATUS_CODES hash to lookup
72 # the default message. If it is a symbol, use the SYMBOL_TO_STATUS_CODE
74 def interpret_status(status
)
77 "#{status} #{STATUS_CODES[status]}".strip
79 interpret_status(SYMBOL_TO_STATUS_CODE
[status
] ||
80 "500 Unknown Status #{status.inspect}")
85 private :interpret_status