Sha256: 175f65ff4323a74790ee300ecdeeb6fd63a0295863329f0e9f23257006f8470a

Contents?: true

Size: 1.15 KB

Versions: 139

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Aws
  module S3
    module Plugins
      class Redirects < Seahorse::Client::Plugin

        option(:follow_redirects,
          default: true,
          doc_type: 'Boolean',
          docstring: <<-DOCS)
When `true`, this client will follow 307 redirects returned
by Amazon S3.
          DOCS

        # @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']
              unless context.http_request.endpoint.host.include?('fips')
                context.http_request.endpoint = endpoint
              end
              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
end

Version data entries

139 entries across 139 versions & 1 rubygems

Version Path
aws-sdk-s3-1.173.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.172.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.171.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.170.1 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.170.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.169.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.168.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.167.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.166.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.165.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.164.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.163.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.162.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.161.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.160.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.159.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.158.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.157.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.156.0 lib/aws-sdk-s3/plugins/redirects.rb
aws-sdk-s3-1.155.0 lib/aws-sdk-s3/plugins/redirects.rb