Class: Excon::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/excon/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
13
14
15
# File 'lib/excon/response.rb', line 6

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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/excon/response.rb', line 4

def body
  @body
end

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/excon/response.rb', line 4

def data
  @data
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/excon/response.rb', line 4

def headers
  @headers
end

#remote_ipObject

Returns the value of attribute remote_ip.



4
5
6
# File 'lib/excon/response.rb', line 4

def remote_ip
  @remote_ip
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/excon/response.rb', line 4

def status
  @status
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/excon/response.rb', line 17

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

#get_header(name) ⇒ Object

Retrieve a specific header value. Header names are treated case-insensitively.

@param [String] name Header name


28
29
30
31
32
33
34
35
# File 'lib/excon/response.rb', line 28

def get_header(name)
  headers.each do |key,value|
    if key.casecmp(name) == 0
      return value
    end
  end
  nil
end

#paramsObject



21
22
23
24
# File 'lib/excon/response.rb', line 21

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