Class: Seahorse::Client::Http::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Response

Returns a new instance of Response.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :status_code (Integer) — default: 0
  • :headers (Headers) — default: Headers.new
  • :body (IO) — default: StringIO.new


9
10
11
12
13
# File 'lib/seahorse/client/http/response.rb', line 9

def initialize(options = {})
  @status_code = options[:status_code] || 0
  @headers = options[:headers] || Headers.new
  @body = options[:body] || StringIO.new
end

Instance Attribute Details

#bodyIO

Returns:

  • (IO)


23
24
25
# File 'lib/seahorse/client/http/response.rb', line 23

def body
  @body
end

#headersHeaders

Returns:



20
21
22
# File 'lib/seahorse/client/http/response.rb', line 20

def headers
  @headers
end

#status_codeInteger

Returns ‘0` if the request failed to generate any response.

Returns:

  • (Integer)

    Returns ‘0` if the request failed to generate any response.



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

def status_code
  @status_code
end

Instance Method Details

#body_contentsString

Returns:

  • (String)


35
36
37
38
39
40
# File 'lib/seahorse/client/http/response.rb', line 35

def body_contents
  body.rewind
  contents = body.read
  body.rewind
  contents
end