Sha256: 05e23f47c278258e6c9304a341ef1496c5c30b120da1b3b1864886b35999c689

Contents?: true

Size: 1.24 KB

Versions: 978

Compression:

Stored size: 1.24 KB

Contents

module Aws
  module Plugins

    # A handful of Amazon S3 operations will respond with a 200 status
    # code but will send an error in the response body. This plugin
    # injects a handler that will parse 200 response bodies for potential
    # errors, allowing them to be retried.
    # @api private
    class S3Http200Errors < Seahorse::Client::Plugin

      class Handler < Seahorse::Client::Handler

        def call(context)
          @handler.call(context).on(200) do |response|
            if error = check_for_error(context)
              context.http_response.status_code = 500
              response.data = nil
              response.error = error
            end
          end
        end

        def check_for_error(context)
          xml = context.http_response.body_contents
          if xml.match(/<Error>/)
            error_code = xml.match(/<Code>(.+?)<\/Code>/)[1]
            error_message = xml.match(/<Message>(.+?)<\/Message>/)[1]
            S3::Errors.error_class(error_code).new(context, error_message)
          end
        end

      end

      handler(Handler,
        step: :sign,
        operations: [
          :complete_multipart_upload,
          :copy_object,
          :upload_part_copy,
        ]
      )

    end
  end
end

Version data entries

978 entries across 978 versions & 2 rubygems

Version Path
aws-sdk-core-2.11.632 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.631 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.630 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.629 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.628 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.627 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.626 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.625 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.624 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.623 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.622 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.621 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.620 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.619 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.618 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.617 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.616 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.615 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.614 lib/aws-sdk-core/plugins/s3_http_200_errors.rb
aws-sdk-core-2.11.613 lib/aws-sdk-core/plugins/s3_http_200_errors.rb