A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/sdkforruby/api/Seahorse/Client/Request.html below:

Request — AWS SDK for Ruby V2

You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Seahorse::Client::Request
Inherits:
Object show all
Includes:
HandlerBuilder
Defined in:
aws-sdk-core/lib/seahorse/client/request.rb
Instance Attribute Summary collapse Instance Method Summary collapse Methods included from HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details #initialize(handlers, context) ⇒ Request

Returns a new instance of Request.

9
10
11
12
# File 'aws-sdk-core/lib/seahorse/client/request.rb', line 9

def initialize(handlers, context)
  @handlers = handlers
  @context = context
end
Instance Attribute Details #contextRequestContext
18
19
20
# File 'aws-sdk-core/lib/seahorse/client/request.rb', line 18

def context
  @context
end
#handlersHandlerList
15
16
17
# File 'aws-sdk-core/lib/seahorse/client/request.rb', line 15

def handlers
  @handlers
end
Instance Method Details #send_request(options = {}, &block) ⇒ Response

Sends the request, returning a Seahorse::Client::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.

request.send_request(target: '/path/to/target/file')

File.open('photo.jpg', 'wb') do |file|
  request.send_request(target: file)
end

Please Note: The target IO object may receive #truncate(0) if the request generates a networking error and bytes have already been written to the target.

Block Streaming

Pass a block to #send_request and the response will be yielded in chunks to the given block.

request.send_request do |chunk|
  file.write(chunk)
end

Please Note: When streaming to a block, it is not possible to retry failed requests.

68
69
70
71
# File 'aws-sdk-core/lib/seahorse/client/request.rb', line 68

def send_request(options = {}, &block)
  @context[:response_target] = options[:target] || block
  @handlers.to_stack.call(@context)
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4