Sha256: d457998ab3e86408d7b712baae1195527e7026e0b565572bb19d87941d2e10f7

Contents?: true

Size: 971 Bytes

Versions: 1052

Compression:

Stored size: 971 Bytes

Contents

module Aws
  module Plugins

    # @seahorse.client.option [Boolean] :follow_redirects (true)
    #   When `true`, this client will follow 307 redirects returned
    #   by Amazon S3.
    class S3Redirects < Seahorse::Client::Plugin

      option(:follow_redirects, true)

      # @api private
      class Handler < Seahorse::Client::Handler

        def call(context)
          response = @handler.call(context)
          if context.http_response.status_code == 307
            endpoint = context.http_response.headers['location']
            context.http_request.endpoint = endpoint
            context.http_response.body.truncate(0)
            @handler.call(context)
          else
            response
          end
        end

      end

      def add_handlers(handlers, config)
        if config.follow_redirects
          # we want to re-trigger request signing
          handlers.add(Handler, step: :sign, priority: 90)
        end
      end

    end
  end
end

Version data entries

1,052 entries across 1,052 versions & 2 rubygems

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