Class: UnderOs::HTTP::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, data) ⇒ Response

Returns a new instance of Response.



4
5
6
7
# File 'lib/under_os/http/response.rb', line 4

def initialize(response, data)
  @response = response
  @data     = data # raw NSData
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



2
3
4
# File 'lib/under_os/http/response.rb', line 2

def data
  @data
end

Instance Method Details

#bodyObject



13
14
15
# File 'lib/under_os/http/response.rb', line 13

def body
  @body ||= @data.to_s
end

#content_lengthObject



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

def content_length
  headers["Content-Length"].to_i
end

#content_typeObject



21
22
23
# File 'lib/under_os/http/response.rb', line 21

def content_type
  headers["Content-Type"]
end

#headersObject



9
10
11
# File 'lib/under_os/http/response.rb', line 9

def headers
  @response.allHeaderFields
end