Sha256: 8cfca26065b041c2c1396b89f1fa68a783b2b08d1901a30ae7d3112482c2204b

Contents?: true

Size: 1.18 KB

Versions: 200

Compression:

Stored size: 1.18 KB

Contents

require 'time'

module Aws
  module Rest
    module Request
      class Headers

        include Seahorse::Model::Shapes

        # @param [Seahorse::Model::ShapeRef] rules
        def initialize(rules)
          @rules = rules
        end

        # @param [Seahorse::Client::Http::Request] http_req
        # @param [Hash] params
        def apply(http_req, params)
          @rules.shape.members.each do |name, ref|
            value = params[name]
            next if value.nil?
            case ref.location
            when 'header' then apply_header_value(http_req.headers, ref, value)
            when 'headers' then apply_header_map(http_req.headers, ref, value)
            end
          end
        end

        private

        def apply_header_value(headers, ref, value)
          headers[ref.location_name] =
            case ref.shape
            when TimestampShape then value.utc.httpdate
            else value.to_s
            end
        end

        def apply_header_map(headers, ref, values)
          prefix = ref.location_name || ''
          values.each_pair do |name, value|
            headers["#{prefix}#{name}"] = value.to_s
          end
        end

      end
    end
  end
end

Version data entries

200 entries across 200 versions & 2 rubygems

Version Path
aws-sdk-core-2.1.20 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.19 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.18 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.17 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.16 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.15 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.14 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.13 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.12 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.11 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.10 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.9 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.8 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.7 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.5 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.4 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.3 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.2 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.1 lib/aws-sdk-core/rest/request/headers.rb
aws-sdk-core-2.1.0 lib/aws-sdk-core/rest/request/headers.rb