You probably want the default instance available as the top-level method
http_status_codes
.
nitcorn $ HttpStatusCodes :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# Helper class to associate HTTP status code to their message
#
# You probably want the default instance available as the top-level method
# `http_status_codes`.
class HttpStatusCodes
# All know code and their message
var codes = new HashMap[Int, String]
# Init the status `codes` list.
protected init is old_style_init do insert_status_codes
# Get the message associated to the status `code`, return `null` in unknown
fun [](code: Int): nullable String
do
if codes.keys.has(code) then
return codes[code]
else return null
end
private fun insert_status_codes
do
codes[100] = "Continue"
codes[101] = "Switching Protocols"
codes[200] = "OK"
codes[201] = "Created"
codes[202] = "Accepted"
codes[203] = "Non-Authoritative Information"
codes[204] = "No Content"
codes[205] = "Reset Content"
codes[206] = "Partial Content"
codes[300] = "Multiple Choices"
codes[301] = "Moved Permanently"
codes[302] = "Found"
codes[303] = "See Other"
codes[304] = "Not Modified"
codes[305] = "Use Proxy"
codes[307] = "Temporary Redirect"
codes[400] = "Bad Request"
codes[401] = "Unauthorized"
codes[402] = "Payment Requred"
codes[403] = "Forbidden"
codes[404] = "Not Found"
codes[405] = "Method Not Allowed"
codes[406] = "Not Acceptable"
codes[407] = "Proxy Authentication Required"
codes[408] = "Request Timeout"
codes[409] = "Conflict"
codes[410] = "Gone"
codes[411] = "Length Required"
codes[412] = "Precondition Failed"
codes[413] = "Request Entity Too Large"
codes[414] = "Request-URI Too Long"
codes[415] = "Unsupported Media Type"
codes[416] = "Requested Range Not Satisfiable"
codes[417] = "Expectation Failed"
codes[500] = "Internal Server Error"
codes[501] = "Not Implemented"
codes[502] = "Bad Gateway"
codes[503] = "Service Unavailable"
codes[504] = "Gateway Timeout"
codes[505] = "HTTP Version Not Supported"
end
end
lib/nitcorn/http_response.nit:109,1--172,3