class Seahorse::Client::Request
def close_managed_files
def close_managed_files [ @context.http_request.body, @context.http_response.body, ].each do |io| io.close if io.is_a?(ManagedFile) && io.open? end end
def initialize(handlers, context)
-
context
(RequestContext
) -- -
handlers
(HandlerList
) --
def initialize(handlers, context) @handlers = handlers @context = context end
def send_request(options = {}, &block)
-
(Response)
-
Options Hash:
(**options)
-
:target
(String, IO
) -- When specified, the HTTP response
def send_request(options = {}, &block) set_response_target(options, &block) @handlers.to_stack.call(@context) ensure close_managed_files end
def set_response_target(options, &block)
def set_response_target(options, &block) target = options[:target] target ||= block target ||= context.params.delete(:response_target) if target @context.http_response.body = case target when Proc then BlockIO.new(&target) when String, Pathname then ManagedFile.new(target, 'w+b') else target end end end