Class: RightScale::CloudApi::HTTPParent

Inherits:
Object
  • Object
show all
Defined in:
lib/base/helpers/http_parent.rb

Overview

The parent class for HTTPRequest and HTTPResponse.

The class defines generic methods that are used by both Request and Response classes.

Direct Known Subclasses

HTTPRequest, HTTPResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyString?

Returns the response body

Examples:

# no example

Returns:



50
51
52
# File 'lib/base/helpers/http_parent.rb', line 50

def body
  @body
end

#rawNet::HTTPResponse

Returns Net::HTTPResponse object

Examples:

# no example

Returns:

  • (Net::HTTPResponse)


41
42
43
# File 'lib/base/helpers/http_parent.rb', line 41

def raw
  @raw
end

Instance Method Details

#[](header) ⇒ Array

Retrieves the given header values

Examples:

# no example

Parameters:

  • header (Hash)

    The header name.

Returns:

  • (Array)

    The Array of values for the header.



72
73
74
# File 'lib/base/helpers/http_parent.rb', line 72

def [](header)
  @headers[header]
end

#headersHash

Returns all the headers for the current request/response instance

Examples:

# no example

Returns:

  • (Hash)

    The set of headers.



59
60
61
# File 'lib/base/helpers/http_parent.rb', line 59

def headers
  @headers.to_hash
end

#headers_infoString

Displays the current headers in a nice way

Examples:

ec2.response.headers_info #=>
 'content-type: "text/xml;charset=UTF-8", server: "AmazonEC2", something: ["a", "b"]'

Returns:



97
98
99
# File 'lib/base/helpers/http_parent.rb', line 97

def headers_info
  @headers.to_s
end

#is_io?Boolean

Returns true if the current object’s body is an IO instance

Examples:

is_io? #=> false

Returns:

  • (Boolean)

    True if it is an IO and false otherwise.



84
85
86
# File 'lib/base/helpers/http_parent.rb', line 84

def is_io?
  body.is_a?(IO) || body.is_a?(Net::ReadAdapter)
end