Class: Unirest::HttpResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/unirest/http_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ HttpResponse

Returns a new instance of HttpResponse.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/unirest/http_response.rb', line 35

def initialize(http_response)
  @code = http_response.code;
  @headers = http_response.headers
  @raw_body = http_response
  @body = @raw_body
  
  begin
    @body = JSON.parse(@raw_body)
  rescue Exception
  end
  
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



32
33
34
# File 'lib/unirest/http_response.rb', line 32

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



30
31
32
# File 'lib/unirest/http_response.rb', line 30

def code
  @code
end

#headersObject (readonly)

Returns the value of attribute headers.



33
34
35
# File 'lib/unirest/http_response.rb', line 33

def headers
  @headers
end

#raw_bodyObject (readonly)

Returns the value of attribute raw_body.



31
32
33
# File 'lib/unirest/http_response.rb', line 31

def raw_body
  @raw_body
end