Class: Hanami::Http::Status Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/http/status.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An HTTP status

Since:

  • 0.1.0

Constant Summary collapse

ALL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

A set of standard codes and messages for HTTP statuses

Since:

  • 0.1.0

::Rack::Utils::HTTP_STATUS_CODES.dup.merge({
  103 => 'Checkpoint',
  122 => 'Request-URI too long',
  413 => 'Payload Too Large',                            # Rack 1.5 compat
  414 => 'URI Too Long',                                 # Rack 1.5 compat
  416 => 'Range Not Satisfiable',                        # Rack 1.5 compat
  418 => 'I\'m a teapot',
  420 => 'Enhance Your Calm',
  444 => 'No Response',
  449 => 'Retry With',
  450 => 'Blocked by Windows Parental Controls',
  451 => 'Wrong Exchange server',
  499 => 'Client Closed Request',
  506 => 'Variant Also Negotiates',                      # Rack 1.5 compat
  598 => 'Network read timeout error',
  599 => 'Network connect timeout error'
}).freeze

Class Method Summary collapse

Class Method Details

.for_code(code) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a status for the given code

Examples:

require 'hanami/http/status'

Hanami::Http::Status.for_code(418) # => [418, "I'm a teapot"]

Parameters:

  • code (Fixnum)

    a valid HTTP code

Returns:

  • (Array)

    a pair of code and message for an HTTP status

Since:

  • 0.1.0


45
46
47
# File 'lib/hanami/http/status.rb', line 45

def self.for_code(code)
  ALL.assoc(code)
end

.message_for(code) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a message for the given status code

Parameters:

  • code (Fixnum)

    a valid HTTP code

Returns:

  • (String)

    a message for the given status code

Since:

  • 0.3.2


57
58
59
# File 'lib/hanami/http/status.rb', line 57

def self.message_for(code)
  for_code(code)[1]
end