Class: Seahorse::Client::Http::Request
- Inherits:
-
Object
- Object
- Seahorse::Client::Http::Request
- Defined in:
- lib/seahorse/client/http/request.rb
Instance Attribute Summary collapse
-
#headers ⇒ Headers
The hash of request headers.
-
#http_method ⇒ String
The HTTP request method, e.g.
Instance Method Summary collapse
- #body ⇒ IO
- #body=(io) ⇒ Object
- #body_contents ⇒ String
- #endpoint ⇒ URI::HTTP, ...
- #endpoint=(endpoint) ⇒ Object
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
13 14 15 16 17 18 |
# File 'lib/seahorse/client/http/request.rb', line 13 def initialize( = {}) self.endpoint = [:endpoint] self.http_method = [:http_method] || 'GET' self.headers = Headers.new([:headers] || {}) self.body = [:body] end |
Instance Attribute Details
#headers ⇒ Headers
Returns The hash of request headers.
24 25 26 |
# File 'lib/seahorse/client/http/request.rb', line 24 def headers @headers end |
#http_method ⇒ String
Returns The HTTP request method, e.g. ‘GET`, `PUT`, etc.
21 22 23 |
# File 'lib/seahorse/client/http/request.rb', line 21 def http_method @http_method end |
Instance Method Details
#body ⇒ IO
44 45 46 |
# File 'lib/seahorse/client/http/request.rb', line 44 def body @body end |
#body=(io) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/seahorse/client/http/request.rb', line 57 def body=(io) @body =case io when nil then StringIO.new('') when String then StringIO.new(io) else io end end |
#body_contents ⇒ String
49 50 51 52 53 54 |
# File 'lib/seahorse/client/http/request.rb', line 49 def body_contents body.rewind contents = body.read body.rewind contents end |
#endpoint ⇒ URI::HTTP, ...
27 28 29 |
# File 'lib/seahorse/client/http/request.rb', line 27 def endpoint @endpoint end |
#endpoint=(endpoint) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/seahorse/client/http/request.rb', line 32 def endpoint=(endpoint) endpoint = URI.parse(endpoint) if endpoint.is_a?(String) if endpoint.nil? or URI::HTTP === endpoint or URI::HTTPS === endpoint @endpoint = endpoint else msg = "invalid endpoint, expected URI::HTTP, URI::HTTPS, or nil, " msg << "got #{endpoint.inspect}" raise ArgumentError, msg end end |