Sha256: 2d7380187cd3d148baea813415d2f74fc1dde8181e4450b47383e0624393397e
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
module Seahorse module Client class Request include HandlerBuilder # @param [HandlerList] handlers # @param [RequestContext] context def initialize(handlers, context) @handlers = handlers @context = context end # @return [HandlerList] attr_reader :handlers # @return [RequestContext] attr_reader :context # Sends the request, returning a {Response} object. # # response = request.send_request # # # Streaming Responses # # By default, HTTP responses are buffered into memory. This can be # bad if you are downloading large responses, e.g. large files. # You can avoid this by streaming the response to a block or some other # target. # # ## Streaming to a File # # You can stream the raw HTTP response body to a File, or any IO-like # object, by passing the `:target` option. # # File.open('photo.jpg', 'wb') do |file| # request.send_request(target: file) # end # # ## Block Streaming # # Pass a block to `#send_request` and the response will be yielded in # chunks to the given block. # # # stream the response data # request.send_request do |chunk| # file.write(chunk) # end # # **Please Note**: When streaming to a block, it is not possible to # retry failed requests. # # @return [Response] def send_request(options = {}, &block) @context.http_response.body = BlockIO.new(&block) if block_given? @context.http_response.body = options[:target] if options[:target] @handlers.to_stack.call(@context) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aws-sdk-core-2.0.0.rc1 | vendor/seahorse/lib/seahorse/client/request.rb |