Class: HTTY::Response

Inherits:
Payload show all
Defined in:
lib/htty/response.rb

Overview

Encapsulates an HTTP(S) response.

Constant Summary

COOKIES_HEADER_NAME =
'Set-Cookie'
LOCATION_HEADER_NAME =
'Location'

Instance Attribute Summary (collapse)

Attributes inherited from Payload

#body

Instance Method Summary (collapse)

Methods inherited from Payload

#==, #headers

Constructor Details

- (Response) initialize(attributes = {})

Initializes a new HTTY::Response with attribute values specified in the attributes hash.

Valid attributes keys include:

  • :body

  • :headers

  • :status



23
24
25
26
# File 'lib/htty/response.rb', line 23

def initialize(attributes={})
  super attributes
  @status = attributes[:status]
end

Instance Attribute Details

- (Object) status (readonly)

Returns the HTTP status associated with the response.



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

def status
  @status
end

Instance Method Details

- (Object) cookies

Returns an array of the cookies belonging to the response.



29
30
31
# File 'lib/htty/response.rb', line 29

def cookies
  HTTY::CookiesUtil.cookies_from_string @headers[COOKIES_HEADER_NAME]
end