class Seahorse::Client::Http::Request
Attributes
headers[RW]
@return [Headers] The hash of request headers.
http_method[RW]
@return [String] The HTTP request method, e.g. `GET`, `PUT`, etc.
Public Class Methods
new(options = {})
click to toggle source
@option options [URI::HTTP, URI::HTTPS] :endpoint (nil) @option options [String] :http_method ('GET') @option options [Headers] :headers (Headers.new) @option options [Body] :body (StringIO.new)
# File lib/seahorse/client/http/request.rb, line 13 def initialize(options = {}) self.endpoint = options[:endpoint] self.http_method = options[:http_method] || 'GET' self.headers = Headers.new(options[:headers] || {}) self.body = options[:body] end
Public Instance Methods
body()
click to toggle source
@return [IO]
# File lib/seahorse/client/http/request.rb, line 44 def body @body end
body=(io)
click to toggle source
@param [#read, size, rewind] io
# 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()
click to toggle source
@return [String]
# File lib/seahorse/client/http/request.rb, line 49 def body_contents body.rewind contents = body.read body.rewind contents end
endpoint()
click to toggle source
@return [URI::HTTP, URI::HTTPS, nil]
# File lib/seahorse/client/http/request.rb, line 27 def endpoint @endpoint end
endpoint=(endpoint)
click to toggle source
@param [String, URI::HTTP, URI::HTTPS, nil] endpoint
# 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