Sha256: 5c12999c840a604a2ecd28eb01cefc46a5613ed1cfc977a55d16f115ec413790

Contents?: true

Size: 870 Bytes

Versions: 3

Compression:

Stored size: 870 Bytes

Contents

module Excon
  class Response

    attr_accessor :body, :data, :headers, :status, :remote_ip

    def initialize(params={})
      @data = {
        :body     => '',
        :headers  => {}
      }.merge(params)
      @body      = @data[:body]
      @headers   = @data[:headers]
      @status    = @data[:status]
      @remote_ip = @data[:remote_ip]
    end

    def [](key)
      @data[key]
    end

    def params
      $stderr.puts("Excon::Response#params is deprecated use Excon::Response#data instead (#{caller.first})")
      data
    end

    # Retrieve a specific header value. Header names are treated case-insensitively.
    #   @param [String] name Header name
    def get_header(name)
      headers.each do |key,value|
        if key.casecmp(name) == 0
          return value
        end
      end
      nil
    end

  end # class Response
end # module Excon

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
excon-0.18.2 lib/excon/response.rb
excon-0.18.1 lib/excon/response.rb
excon-0.18.0 lib/excon/response.rb