Sha256: bb1ceff52a9b5a7b15bd4adaa47bf6c1d157058b0a9b9a41130652e5e242850a

Contents?: true

Size: 687 Bytes

Versions: 14

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true

class EzClient::Response
  attr_accessor :http_response, :body

  def initialize(http_response)
    self.http_response = http_response
    self.body = http_response.body.to_s # Make sure we read the body for persistent connection
  end

  def headers
    http_response.headers
  end

  def code
    http_response.code
  end
  alias status code

  def cookies
    http_response.cookies
  end

  def ok?
    code.between?(200, 299)
  end

  def redirect?
    code.between?(300, 399)
  end

  def client_error?
    code.between?(400, 499)
  end

  def server_error?
    code.between?(500, 599)
  end

  def error?
    client_error? || server_error?
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ezclient-1.6.0 lib/ezclient/response.rb
ezclient-1.5.1 lib/ezclient/response.rb
ezclient-1.5.0 lib/ezclient/response.rb
ezclient-1.4.0 lib/ezclient/response.rb
ezclient-1.3.0 lib/ezclient/response.rb
ezclient-1.2.0 lib/ezclient/response.rb
ezclient-1.1.0 lib/ezclient/response.rb
ezclient-1.0.0 lib/ezclient/response.rb
ezclient-0.16.0 lib/ezclient/response.rb
ezclient-0.15.3 lib/ezclient/response.rb
ezclient-0.15.2 lib/ezclient/response.rb
ezclient-0.15.1 lib/ezclient/response.rb
ezclient-0.15.0 lib/ezclient/response.rb
ezclient-0.14.0 lib/ezclient/response.rb