Class: Spec::Client::Http::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Response

Returns a new instance of Response.



11
12
13
14
15
16
# File 'lib/spec/client/http/response.rb', line 11

def initialize(url)
  @code = 0
  @headers = {}
  @body = ""
  @url = url
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

#headersObject

Returns the value of attribute headers.



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

def headers
  @headers
end

Instance Method Details

#cookiesObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/spec/client/http/response.rb', line 18

def cookies
  # TODO: can probably use ruby tricks to bind these together rather than using a temporary array...
  tmp_cookies = []
  (headers["Set-Cookie"]||[]).map do |raw_cookie|
    uri = URI::parse(@url)
    Mechanize::Cookie::parse(uri,raw_cookie) do |c|
      tmp_cookies.push(c)
    end
  end
  tmp_cookies
end