enum HTTP::Status

Overview

An enum that provides additional support around HTTP status codes.

Based on Hypertext Transfer Protocol (HTTP) Status Code Registry

It provides constants for the defined HTTP status codes as well as helper methods to easily identify the type of response.

Defined in:

http/status.cr

Enum Members

CONTINUE = 100
SWITCHING_PROTOCOLS = 101
PROCESSING = 102
EARLY_HINTS = 103
OK = 200
CREATED = 201
ACCEPTED = 202
NON_AUTHORITATIVE_INFORMATION = 203
NO_CONTENT = 204
RESET_CONTENT = 205
PARTIAL_CONTENT = 206
MULTI_STATUS = 207
ALREADY_REPORTED = 208
IM_USED = 226
MULTIPLE_CHOICES = 300
MOVED_PERMANENTLY = 301
FOUND = 302
SEE_OTHER = 303
NOT_MODIFIED = 304
USE_PROXY = 305
SWITCH_PROXY = 306
TEMPORARY_REDIRECT = 307
PERMANENT_REDIRECT = 308
BAD_REQUEST = 400
UNAUTHORIZED = 401
PAYMENT_REQUIRED = 402
FORBIDDEN = 403
NOT_FOUND = 404
METHOD_NOT_ALLOWED = 405
NOT_ACCEPTABLE = 406
PROXY_AUTHENTICATION_REQUIRED = 407
REQUEST_TIMEOUT = 408
CONFLICT = 409
GONE = 410
LENGTH_REQUIRED = 411
PRECONDITION_FAILED = 412
PAYLOAD_TOO_LARGE = 413
URI_TOO_LONG = 414
UNSUPPORTED_MEDIA_TYPE = 415
RANGE_NOT_SATISFIABLE = 416
EXPECTATION_FAILED = 417
IM_A_TEAPOT = 418
MISDIRECTED_REQUEST = 421
UNPROCESSABLE_ENTITY = 422
LOCKED = 423
FAILED_DEPENDENCY = 424
UPGRADE_REQUIRED = 426
PRECONDITION_REQUIRED = 428
TOO_MANY_REQUESTS = 429
REQUEST_HEADER_FIELDS_TOO_LARGE = 431
UNAVAILABLE_FOR_LEGAL_REASONS = 451
INTERNAL_SERVER_ERROR = 500
NOT_IMPLEMENTED = 501
BAD_GATEWAY = 502
SERVICE_UNAVAILABLE = 503
GATEWAY_TIMEOUT = 504
HTTP_VERSION_NOT_SUPPORTED = 505
VARIANT_ALSO_NEGOTIATES = 506
INSUFFICIENT_STORAGE = 507
LOOP_DETECTED = 508
NOT_EXTENDED = 510
NETWORK_AUTHENTICATION_REQUIRED = 511

Constructors

Instance Method Summary

Instance methods inherited from struct Enum

&(other : self) &, +(other : Int) +, -(other : Int) -, <=>(other : self) <=>, ==(other : self) ==, ^(other : self) ^, clone clone, each(&) each, hash(hasher) hash, includes?(other : self) includes?, to_f32 : Float32 to_f32, to_f32! : Float32 to_f32!, to_f64 : Float64 to_f64, to_f64! : Float64 to_f64!, to_i : Int32 to_i, to_i16 : Int16 to_i16, to_i16! : Int16 to_i16!, to_i32 : Int32 to_i32, to_i32! : Int32 to_i32!, to_i64 : Int64 to_i64, to_i64! : Int64 to_i64!, to_i8 : Int8 to_i8, to_i8! : Int8 to_i8!, to_json(json : JSON::Builder) to_json, to_s(io : IO) : Nil
to_s : String
to_s
, to_u16 : UInt16 to_u16, to_u16! : UInt16 to_u16!, to_u32 : UInt32 to_u32, to_u32! : UInt32 to_u32!, to_u64 : UInt64 to_u64, to_u64! : UInt64 to_u64!, to_u8 : UInt8 to_u8, to_u8! : UInt8 to_u8!, to_yaml(yaml : YAML::Nodes::Builder) to_yaml, |(other : self) |, ~ ~

Constructor methods inherited from struct Enum

from_value(value : Int) : self from_value, from_value?(value : Int) : self? from_value?, new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
new(pull : JSON::PullParser)
new
, parse(string : String) : self parse, parse?(string : String) : self? parse?

Class methods inherited from struct Enum

each(&) each, names : Array(String) names, valid?(value : self) : Bool valid?, values : Array(self) values

Instance methods inherited from module Comparable(Enum)

<(other : T) <, <=(other : T) <=, <=>(other : T) <=>, ==(other : T) ==, >(other : T) >, >=(other : T) >=, clamp(min, max)
clamp(range : Range)
clamp

Instance methods inherited from struct Value

==(other : JSON::Any)
==(other : YAML::Any)
==(other)
==
, dup dup

Instance methods inherited from class Object

! : Bool !, !=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other)
===
, =~(other) =~, as(type : Class) as, as?(type : Class) as?, class class, dup dup, hash
hash(hasher)
hash
, inspect(io : IO) : Nil
inspect : String
inspect
, is_a?(type : Class) : Bool is_a?, itself itself, nil? : Bool nil?, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, responds_to?(name : Symbol) : Bool responds_to?, tap(&) tap, to_json(io : IO)
to_json
to_json
, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ")
to_pretty_json
, to_s : String
to_s(io : IO) : Nil
to_s
, to_yaml(io : IO)
to_yaml
to_yaml
, try(&) try, unsafe_as(type : T.class) forall T unsafe_as

Class methods inherited from class Object

from_json(string_or_io, root : String)
from_json(string_or_io)
from_json
, from_yaml(string_or_io : String | IO) from_yaml

Constructor Detail

def self.new(status_code : Int32) #

Create a new status instance with the given status code, or raise an error if the status code given is not inside 100..999.


[View source]

Instance Method Detail

def accepted? #

[View source]
def already_reported? #

[View source]
def bad_gateway? #

[View source]
def bad_request? #

[View source]
def client_error? #

Returns true if the response status code is between 400 and 499.


[View source]
def code #

[View source]
def conflict? #

[View source]
def continue? #

[View source]
def created? #

[View source]
def description : String? #

Returns the default status description of the given HTTP status code.


[View source]
def early_hints? #

[View source]
def expectation_failed? #

[View source]
def failed_dependency? #

[View source]
def forbidden? #

[View source]
def found? #

[View source]
def gateway_timeout? #

[View source]
def gone? #

[View source]
def http_version_not_supported? #

[View source]
def im_a_teapot? #

[View source]
def im_used? #

[View source]
def informational? #

Returns true if the response status code is between 100 and 199.


[View source]
def insufficient_storage? #

[View source]
def internal_server_error? #

[View source]
def length_required? #

[View source]
def locked? #

[View source]
def loop_detected? #

[View source]
def method_not_allowed? #

[View source]
def misdirected_request? #

[View source]
def moved_permanently? #

[View source]
def multi_status? #

[View source]
def multiple_choices? #

[View source]
def network_authentication_required? #

[View source]
def no_content? #

[View source]
def non_authoritative_information? #

[View source]
def not_acceptable? #

[View source]
def not_extended? #

[View source]
def not_found? #

[View source]
def not_implemented? #

[View source]
def not_modified? #

[View source]
def ok? #

[View source]
def partial_content? #

[View source]
def payload_too_large? #

[View source]
def payment_required? #

[View source]
def permanent_redirect? #

[View source]
def precondition_failed? #

[View source]
def precondition_required? #

[View source]
def processing? #

[View source]
def proxy_authentication_required? #

[View source]
def range_not_satisfiable? #

[View source]
def redirection? #

Returns true if the response status code is between 300 and 399.


[View source]
def request_header_fields_too_large? #

[View source]
def request_timeout? #

[View source]
def reset_content? #

[View source]
def see_other? #

[View source]
def server_error? #

Returns true if the response status code is between 500 and 599.


[View source]
def service_unavailable? #

[View source]
def success? #

Returns true if the response status code is between 200 and 299.


[View source]
def switch_proxy? #

[View source]
def switching_protocols? #

[View source]
def temporary_redirect? #

[View source]
def too_many_requests? #

[View source]
def unauthorized? #

[View source]
def unavailable_for_legal_reasons? #

[View source]
def unprocessable_entity? #

[View source]
def unsupported_media_type? #

[View source]
def upgrade_required? #

[View source]
def uri_too_long? #

[View source]
def use_proxy? #

[View source]
def variant_also_negotiates? #

[View source]