Parent

HTTPI::Response

HTTPI::Response

Represents an HTTP response and contains various response details.

Constants

SuccessfulResponseCodes

Range of HTTP response codes considered to be successful.

Attributes

attachments[RW]
body[W]
code[RW]
headers[RW]
raw_body[RW]

Public Class Methods

new(code, headers, body) click to toggle source

Initializer expects an HTTP response code, headers and body.

# File lib/httpi/response.rb, line 17
def initialize(code, headers, body)
  self.code = code.to_i
  self.headers = Rack::Utils::HeaderHash.new(headers)
  self.raw_body = body
end

Public Instance Methods

body() click to toggle source

Returns the HTTP response body.

# File lib/httpi/response.rb, line 42
def body
  decode_body unless @body
  @body
end
error?() click to toggle source

Returns whether the HTTP response is considered successful.

# File lib/httpi/response.rb, line 26
def error?
  !SuccessfulResponseCodes.include? code.to_i
end
multipart?() click to toggle source

Returns whether the HTTP response is a multipart response.

# File lib/httpi/response.rb, line 31
def multipart?
  !!(headers["Content-Type"] =~ /^multipart/)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.