class Aws::S3::Plugins::StreamingRetry::Handler
Public Instance Methods
call(context)
click to toggle source
# File lib/aws-sdk-s3/plugins/streaming_retry.rb, line 53 def call(context) target = context.params[:response_target] || context[:response_target] # retry is only supported when range is NOT set on the initial request if supported_target?(target) && !context.params[:range] add_event_listeners(context, target) end @handler.call(context) end
Private Instance Methods
add_event_listeners(context, target)
click to toggle source
# File lib/aws-sdk-s3/plugins/streaming_retry.rb, line 65 def add_event_listeners(context, target) context.http_response.on_headers(200..299) do case context.http_response.body when Seahorse::Client::BlockIO then context.http_response.body = RetryableBlockIO.new(context.http_response.body) when Seahorse::Client::ManagedFile then context.http_response.body = RetryableManagedFile.new(context.http_response.body) end end context.http_response.on_headers(400..599) do context.http_response.body = StringIO.new # something to write the error to end context.http_response.on_success(200..299) do body = context.http_response.body if body.is_a?(RetryableManagedFile) && body.open? body.close end end context.http_response.on_error do |error| if retryable_body?(context) && truncated_body?(error) context.http_request.headers[:range] = "bytes=#{context.http_response.body.size}-" end end end
retryable_body?(context)
click to toggle source
# File lib/aws-sdk-s3/plugins/streaming_retry.rb, line 100 def retryable_body?(context) context.http_response.body.is_a?(RetryableBlockIO) || context.http_response.body.is_a?(RetryableManagedFile) end
supported_target?(target)
click to toggle source
# File lib/aws-sdk-s3/plugins/streaming_retry.rb, line 105 def supported_target?(target) case target when Proc, String, Pathname then true else false end end
truncated_body?(error)
click to toggle source
# File lib/aws-sdk-s3/plugins/streaming_retry.rb, line 93 def truncated_body?(error) error.is_a?(Seahorse::Client::NetworkingError) && error.original_error.is_a?( Seahorse::Client::NetHttp::Handler::TruncatedBodyError ) end