Module: K8

Defined in:
lib/keight.rb

Defined Under Namespace

Modules: Util Classes: Action, ActionInfo, ActionInfo0, ActionInfo1, ActionInfo2, ActionInfo3, ActionInfo4, ActionMapping, ActionMappingError, BaseAction, BaseError, ContentTypeRequiredError, HttpException, PayloadParseError, RackApplication, RackRequest, RackResponse, UnknownActionMethodError, UnknownContentError, UploadedFile

Constant Summary collapse

RELEASE =
'$Release: 0.3.0 $'.split()[1]
FILEPATH =
__FILE__
HTTP_REQUEST_METHODS =
{
  "GET"     => :GET,
  "POST"    => :POST,
  "PUT"     => :PUT,
  "DELETE"  => :DELETE,
  "HEAD"    => :HEAD,
  "PATCH"   => :PATCH,
  "OPTIONS" => :OPTIONS,
  "TRACE"   => :TRACE,
}
HTTP_RESPONSE_STATUS =
{
  100 => "Continue",
  101 => "Switching Protocols",
  102 => "Processing",                           # WebDAV; RFC 2518
  103 => "Checkpoint",                           # Unofficial
  200 => "OK",
  201 => "Created",
  202 => "Accepted",
  203 => "Non-Authoritative Information",        # since HTTP/1.1
  204 => "No Content",
  205 => "Reset Content",
  206 => "Partial Content",                      # RFC 7233
  207 => "Multi-Status",                         # WebDAV; RFC 4918
  208 => "Already Reported",                     # WebDAV; RFC 5842
  226 => "IM Used",                              # RFC 3229
  300 => "Multiple Choices",
  301 => "Moved Permanently",
  302 => "Found",
  303 => "See Other",                            # since HTTP/1.1
  304 => "Not Modified",                         # RFC 7232
  305 => "Use Proxy",                            # since HTTP/1.1
  306 => "Switch Proxy",
  307 => "Temporary Redirect",                   # since HTTP/1.1
  308 => "Permanent Redirect",                   # RFC 7538
  400 => "Bad Request",
  401 => "Unauthorized",                         # RFC 7235
  402 => "Payment Required",
  403 => "Forbidden",
  404 => "Not Found",
  405 => "Method Not Allowed",
  406 => "Not Acceptable",
  407 => "Proxy Authentication Required",        # RFC 7235
  408 => "Request Timeout",
  409 => "Conflict",
  410 => "Gone",
  411 => "Length Required",
  412 => "Precondition Failed",                  # RFC 7232
  413 => "Payload Too Large",                    # RFC 7231
  414 => "URI Too Long",                         # RFC 7231
  415 => "Unsupported Media Type",
  416 => "Range Not Satisfiable",                # RFC 7233
  417 => "Expectation Failed",
  418 => "I'm a teapot",                         # RFC 2324
 #420 => "Enhance Your Calm",                    # Twitter
 #420 => "Method Failure",                       # Spring Framework
  421 => "Misdirected Request",                  # RFC 7540
  422 => "Unprocessable Entity",                 # WebDAV; RFC 4918
  423 => "Locked",                               # WebDAV; RFC 4918
  424 => "Failed Dependency",                    # WebDAV; RFC 4918
  426 => "Upgrade Required",
  428 => "Precondition Required",                # RFC 6585
  429 => "Too Many Requests",                    # RFC 6585
  431 => "Request Header Fields Too Large",      # RFC 6585
 #440 => "Login Timeout",                        # IIS
  444 => "No Response",                          # nginx
 #449 => "Retry With",                           # IIS
 #450 => "Blocked by Windows Parental Controls", # Microsoft
 #451 => "Redirect",                             # IIS
  451 => "Unavailable For Legal Reasons",
  495 => "SSL Certificate Error",                # nginx
  496 => "SSL Certificate Required",             # nginx
  497 => "HTTP Request Sent to HTTPS Port",      # nginx
 #498 => "Invalid Token",                        # Esri
  499 => "Client Closed Request",                # nginx
 #499 => "Request has been forbidden by antivirus",
 #499 => "Token Required",                       # Esri
  500 => "Internal Server Error",
  501 => "Not Implemented",
  502 => "Bad Gateway",
  503 => "Service Unavailable",
  504 => "Gateway Timeout",
  505 => "HTTP Version Not Supported",
  506 => "Variant Also Negotiates",              # RFC 2295
  507 => "Insufficient Storage",                 # WebDAV; RFC 4918
  508 => "Loop Detected",                        # WebDAV; RFC 5842
  509 => "Bandwidth Limit Exceeded",             # Apache Web Server/cPanel
  510 => "Not Extended",                         # RFC 2774
  511 => "Network Authentication Required",      # RFC 6585
  520 => "Unknown Error",                        # CloudFlare
  521 => "Web Server Is Down",                   # CloudFlare
  522 => "Connection Timed Out",                 # CloudFlare
  523 => "Origin Is Unreachable",                # CloudFlare
  524 => "A Timeout Occurred",                   # CloudFlare
  525 => "SSL Handshake Failed",                 # CloudFlare
  526 => "Invalid SSL Certificate",              # CloudFlare
 #530 => "Site is frozen",                       # Unofficial
}.each {|_, v| v.freeze }
MIME_TYPES =
{
  '.html'    => 'text/html',
  '.htm'     => 'text/html',
  '.shtml'   => 'text/html',
  '.css'     => 'text/css',
  '.csv'     => 'text/comma-separated-values',
  '.tsv'     => 'text/tab-separated-values',
  '.xml'     => 'text/xml',
  '.mml'     => 'text/mathml',
  '.txt'     => 'text/plain',
  '.wml'     => 'text/vnd.wap.wml',
  '.gif'     => 'image/gif',
  '.jpeg'    => 'image/jpeg',
  '.jpg'     => 'image/jpeg',
  '.png'     => 'image/png',
  '.tif'     => 'image/tiff',
  '.tiff'    => 'image/tiff',
  '.ico'     => 'image/x-icon',
  '.bmp'     => 'image/x-ms-bmp',
  '.svg'     => 'image/svg+xml',
  '.svgz'    => 'image/svg+xml',
  '.webp'    => 'image/webp',
  '.mid'     => 'audio/midi',
  '.midi'    => 'audio/midi',
  '.kar'     => 'audio/midi',
  '.mp3'     => 'audio/mpeg',
  '.ogg'     => 'audio/ogg',
  '.m4a'     => 'audio/x-m4a',
  '.ra'      => 'audio/x-realaudio',
  '.3gpp'    => 'video/3gpp',
  '.3gp'     => 'video/3gpp',
  '.3g2'     => 'video/3gpp2',
  '.ts'      => 'video/mp2t',
  '.mp4'     => 'video/mp4',
  '.mpeg'    => 'video/mpeg',
  '.mpg'     => 'video/mpeg',
  '.mov'     => 'video/quicktime',
  '.webm'    => 'video/webm',
  '.flv'     => 'video/x-flv',
  '.m4v'     => 'video/x-m4v',
  '.mng'     => 'video/x-mng',
  '.asx'     => 'video/x-ms-asf',
  '.asf'     => 'video/x-ms-asf',
  '.wmv'     => 'video/x-ms-wmv',
  '.avi'     => 'video/x-msvideo',
  '.json'    => 'application/json',
  '.js'      => 'application/javascript',
  '.atom'    => 'application/atom+xml',
  '.rss'     => 'application/rss+xml',
  '.doc'     => 'application/msword',
  '.pdf'     => 'application/pdf',
  '.ps'      => 'application/postscript',
  '.eps'     => 'application/postscript',
  '.ai'      => 'application/postscript',
  '.rtf'     => 'application/rtf',
  '.xls'     => 'application/vnd.ms-excel',
  '.eot'     => 'application/vnd.ms-fontobject',
  '.ppt'     => 'application/vnd.ms-powerpoint',
  '.key'     => 'application/vnd.apple.keynote',
  '.pages'   => 'application/vnd.apple.pages',
  '.numbers' => 'application/vnd.apple.numbers',
  '.zip'     => 'application/zip',
  '.lha'     => 'application/x-lzh',
  '.lzh'     => 'application/x-lzh',
  '.tar'     => 'application/x-tar',
  '.tgz'     => 'application/x-tar',
  '.gz'      => 'application/x-gzip',
  '.bz2'     => 'application/x-bzip2',
  '.xz'      => 'application/x-xz',
  '.7z'      => 'application/x-7z-compressed',
  '.rar'     => 'application/x-rar-compressed',
  '.rpm'     => 'application/x-redhat-package-manager',
  '.deb'     => 'application/vnd.debian.binary-package',
  '.swf'     => 'application/x-shockwave-flash',
  '.der'     => 'application/x-x509-ca-cert',
  '.pem'     => 'application/x-x509-ca-cert',
  '.crt'     => 'application/x-x509-ca-cert',
  '.xpi'     => 'application/x-xpinstall',
  '.xhtml'   => 'application/xhtml+xml',
  '.xspf'    => 'application/xspf+xml',
  '.yaml'    => 'application/x-yaml',
  '.yml'     => 'application/x-yaml',
  '.docx'    => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  '.xlsx'    => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  '.pptx'    => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
}.each {|_, v| v.freeze }