Class: Foobara::CommandConnectors::Http::Response

Inherits:
Foobara::CommandConnector::Response show all
Defined in:
foobara-http-command-connector-0.0.23/src/http/response.rb

Instance Attribute Summary collapse

Attributes inherited from Foobara::CommandConnector::Response

#body, #request, #status

Instance Method Summary collapse

Methods inherited from Foobara::CommandConnector::Response

#command, #error, #success?

Constructor Details

#initialize(headers: nil, cookies: nil) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
# File 'foobara-http-command-connector-0.0.23/src/http/response.rb', line 8

def initialize(headers: nil, cookies: nil, **)
  self.headers = headers
  self.cookies = cookies

  super(**)
end

Instance Attribute Details

#cookiesObject



15
16
17
# File 'foobara-http-command-connector-0.0.23/src/http/response.rb', line 15

def cookies
  @cookies ||= []
end

#headersObject

Returns the value of attribute headers.



5
6
7
# File 'foobara-http-command-connector-0.0.23/src/http/response.rb', line 5

def headers
  @headers
end

Instance Method Details



19
20
21
# File 'foobara-http-command-connector-0.0.23/src/http/response.rb', line 19

def add_cookie(cookie_name, cookie_value, cookie_opts)
  cookies << Cookie.new(cookie_name, cookie_value, **cookie_opts)
end

#add_header(header_name, header_value) ⇒ Object



23
24
25
26
# File 'foobara-http-command-connector-0.0.23/src/http/response.rb', line 23

def add_header(header_name, header_value)
  self.headers ||= {}
  headers[header_name] = header_value
end