class Aws::Rest::Request::Headers

Public Class Methods

new(rules) click to toggle source

@param [Seahorse::Model::ShapeRef] rules

# File lib/aws-sdk-core/rest/request/headers.rb, line 11
def initialize(rules)
  @rules = rules
end

Public Instance Methods

apply(http_req, params) click to toggle source

@param [Seahorse::Client::Http::Request] http_req @param [Hash] params

# File lib/aws-sdk-core/rest/request/headers.rb, line 17
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 Instance Methods

apply_header_map(headers, ref, values) click to toggle source
# File lib/aws-sdk-core/rest/request/headers.rb, line 38
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
apply_header_value(headers, ref, value) click to toggle source
# File lib/aws-sdk-core/rest/request/headers.rb, line 30
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