Sha256: 2bd972dde9af0f78a5376a66b5ec7e47701acebee2fd38c65d3fdb6d26fb3c8d
Contents?: true
Size: 1016 Bytes
Versions: 1
Compression:
Stored size: 1016 Bytes
Contents
# frozen_string_literal: true class EzClient::Response attr_accessor :http_response, :body, :http_request def initialize(http_response, http_request) self.http_response = http_response self.http_request = http_request 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 def inspect { req: { raw: http_request.inspect, hdrs: http_request.headers, }, resp: { raw: http_response.inspect, hdrs: headers, body: body, }, }.to_s end def to_s inspect end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ezclient-1.7.0 | lib/ezclient/response.rb |