module WEBrick

#
# This module is used to manager HTTP status codes.
#
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more
# information.
module HTTPStatus
  #
  # Root of the HTTP status class hierarchy
  class Status < StandardError
    attr_reader self.code: Integer

    attr_reader self.reason_phrase: String

    # Returns the HTTP status code
    def code: () -> Integer

    # Returns the HTTP status description
    def reason_phrase: () -> String

    alias to_i code
  end

  # Root of the HTTP info statuses
  class Info < Status
  end

  # Root of the HTTP success statuses
  class Success < Status
  end

  # Root of the HTTP redirect statuses
  class Redirect < Status
  end

  # Root of the HTTP error statuses
  class Error < Status
  end

  # Root of the HTTP client error statuses
  class ClientError < Error
  end

  # Root of the HTTP server error statuses
  class ServerError < Error
  end

  class EOFError < StandardError
  end

  # HTTP status codes and descriptions
  StatusMessage: Hash[Integer, String]

  # Maps a status code to the corresponding Status class
  CodeToError: Hash[Integer, singleton(Status)]

  # WEBrick::HTTPStatus::constants.grep(/\ARC_/).map{"#{_1}: #{WEBrick::HTTPStatus.const_get(_1)}"}

  RC_CONTINUE: 100
  RC_SWITCHING_PROTOCOLS: 101
  RC_OK: 200
  RC_CREATED: 201
  RC_ACCEPTED: 202
  RC_NON_AUTHORITATIVE_INFORMATION: 203
  RC_NO_CONTENT: 204
  RC_RESET_CONTENT: 205
  RC_PARTIAL_CONTENT: 206
  RC_MULTI_STATUS: 207
  RC_MULTIPLE_CHOICES: 300
  RC_MOVED_PERMANENTLY: 301
  RC_FOUND: 302
  RC_SEE_OTHER: 303
  RC_NOT_MODIFIED: 304
  RC_USE_PROXY: 305
  RC_TEMPORARY_REDIRECT: 307
  RC_BAD_REQUEST: 400
  RC_UNAUTHORIZED: 401
  RC_PAYMENT_REQUIRED: 402
  RC_FORBIDDEN: 403
  RC_NOT_FOUND: 404
  RC_METHOD_NOT_ALLOWED: 405
  RC_NOT_ACCEPTABLE: 406
  RC_PROXY_AUTHENTICATION_REQUIRED: 407
  RC_REQUEST_TIMEOUT: 408
  RC_CONFLICT: 409
  RC_GONE: 410
  RC_PRECONDITION_FAILED: 412
  RC_LENGTH_REQUIRED: 411
  RC_REQUEST_ENTITY_TOO_LARGE: 413
  RC_REQUEST_URI_TOO_LARGE: 414
  RC_UNSUPPORTED_MEDIA_TYPE: 415
  RC_EXPECTATION_FAILED: 417
  RC_UNPROCESSABLE_ENTITY: 422
  RC_LOCKED: 423
  RC_FAILED_DEPENDENCY: 424
  RC_REQUEST_RANGE_NOT_SATISFIABLE: 416
  RC_UPGRADE_REQUIRED: 426
  RC_PRECONDITION_REQUIRED: 428
  RC_TOO_MANY_REQUESTS: 429
  RC_REQUEST_HEADER_FIELDS_TOO_LARGE: 431
  RC_UNAVAILABLE_FOR_LEGAL_REASONS: 451
  RC_INTERNAL_SERVER_ERROR: 500
  RC_NOT_IMPLEMENTED: 501
  RC_BAD_GATEWAY: 502
  RC_SERVICE_UNAVAILABLE: 503
  RC_GATEWAY_TIMEOUT: 504
  RC_HTTP_VERSION_NOT_SUPPORTED: 505
  RC_INSUFFICIENT_STORAGE: 507
  RC_NETWORK_AUTHENTICATION_REQUIRED: 511

  # WEBrick::HTTPStatus::CodeToError.each_value.map{"class #{_1.name.split(/::/).last} < #{_1.superclass.name.split(/::/).last}\nend"}

  class Continue < Info
  end
  class SwitchingProtocols < Info
  end
  class OK < Success
  end
  class Created < Success
  end
  class Accepted < Success
  end
  class NonAuthoritativeInformation < Success
  end
  class NoContent < Success
  end
  class ResetContent < Success
  end
  class PartialContent < Success
  end
  class MultiStatus < Success
  end
  class MultipleChoices < Redirect
  end
  class MovedPermanently < Redirect
  end
  class Found < Redirect
  end
  class SeeOther < Redirect
  end
  class NotModified < Redirect
  end
  class UseProxy < Redirect
  end
  class TemporaryRedirect < Redirect
  end
  class BadRequest < ClientError
  end
  class Unauthorized < ClientError
  end
  class PaymentRequired < ClientError
  end
  class Forbidden < ClientError
  end
  class NotFound < ClientError
  end
  class MethodNotAllowed < ClientError
  end
  class NotAcceptable < ClientError
  end
  class ProxyAuthenticationRequired < ClientError
  end
  class RequestTimeout < ClientError
  end
  class Conflict < ClientError
  end
  class Gone < ClientError
  end
  class LengthRequired < ClientError
  end
  class PreconditionFailed < ClientError
  end
  class RequestEntityTooLarge < ClientError
  end
  class RequestURITooLarge < ClientError
  end
  class UnsupportedMediaType < ClientError
  end
  class RequestRangeNotSatisfiable < ClientError
  end
  class ExpectationFailed < ClientError
  end
  class UnprocessableEntity < ClientError
  end
  class Locked < ClientError
  end
  class FailedDependency < ClientError
  end
  class UpgradeRequired < ClientError
  end
  class PreconditionRequired < ClientError
  end
  class TooManyRequests < ClientError
  end
  class RequestHeaderFieldsTooLarge < ClientError
  end
  class UnavailableForLegalReasons < ClientError
  end
  class InternalServerError < ServerError
  end
  class NotImplemented < ServerError
  end
  class BadGateway < ServerError
  end
  class ServiceUnavailable < ServerError
  end
  class GatewayTimeout < ServerError
  end
  class HTTPVersionNotSupported < ServerError
  end
  class InsufficientStorage < ServerError
  end
  class NetworkAuthenticationRequired < ServerError
  end

  #
  # Returns the description corresponding to the HTTP status +code+
  #
  #   WEBrick::HTTPStatus.reason_phrase 404
  #   => "Not Found"
  def self?.reason_phrase: (Integer code) -> String

  #
  # Is +code+ an informational status?
  def self?.info?: (Integer code) -> bool

  #
  # Is +code+ a successful status?
  def self?.success?: (Integer code) -> bool

  #
  # Is +code+ a redirection status?
  def self?.redirect?: (Integer code) -> bool

  #
  # Is +code+ an error status?
  def self?.error?: (Integer code) -> bool

  #
  # Is +code+ a client error status?
  def self?.client_error?: (Integer code) -> bool

  #
  # Is +code+ a server error status?
  def self?.server_error?: (Integer code) -> bool

  #
  # Returns the status class corresponding to +code+
  #
  #   WEBrick::HTTPStatus[302]
  #   => WEBrick::HTTPStatus::NotFound
  #
  def self.[]: (Integer code) -> singleton(Status)
end

end