Module: HTTP::Status

Defined in:
lib/httpclient/http.rb

Overview

Represents HTTP response status code. Defines constants for HTTP response and some conditional methods.

Constant Summary collapse

OK =
200
CREATED =
201
ACCEPTED =
202
NON_AUTHORITATIVE_INFORMATION =
203
NO_CONTENT =
204
RESET_CONTENT =
205
PARTIAL_CONTENT =
206
MOVED_PERMANENTLY =
301
FOUND =
302
SEE_OTHER =
303
TEMPORARY_REDIRECT =
MOVED_TEMPORARILY = 307
BAD_REQUEST =
400
UNAUTHORIZED =
401
PROXY_AUTHENTICATE_REQUIRED =
407
INTERNAL =
500
SUCCESSFUL_STATUS =

Status codes for successful HTTP response.

[
  OK, CREATED, ACCEPTED,
  NON_AUTHORITATIVE_INFORMATION, NO_CONTENT,
  RESET_CONTENT, PARTIAL_CONTENT
]
REDIRECT_STATUS =

Status codes which is a redirect.

[
  MOVED_PERMANENTLY, FOUND, SEE_OTHER,
  TEMPORARY_REDIRECT, MOVED_TEMPORARILY
]

Class Method Summary collapse

Class Method Details

.redirect?(status) ⇒ Boolean

Returns true if the given status is thought to be redirect. See also REDIRECT_STATUS.

Returns:

  • (Boolean)


56
57
58
# File 'lib/httpclient/http.rb', line 56

def self.redirect?(status)
  REDIRECT_STATUS.include?(status)
end

.successful?(status) ⇒ Boolean

Returns true if the given status represents successful HTTP response. See also SUCCESSFUL_STATUS.

Returns:

  • (Boolean)


50
51
52
# File 'lib/httpclient/http.rb', line 50

def self.successful?(status)
  SUCCESSFUL_STATUS.include?(status)
end