class Aws::RpcV2::ContentTypeHandler

Public Instance Methods

call(context) click to toggle source
# File lib/aws-sdk-core/rpc_v2/content_type_handler.rb, line 6
def call(context)
  content_type =
    if eventstream_input?(context)
      'application/vnd.amazon.eventstream'
    elsif !empty_input_structure?(context)
      'application/cbor'
    end
  accept =
    if eventstream_output?(context)
      'application/vnd.amazon.eventstream'
    else
      'application/cbor'
    end

  headers = context.http_request.headers
  headers['Content-Type'] ||= content_type if content_type
  headers['Accept'] ||= accept
  @handler.call(context)
end

Private Instance Methods

empty_input_structure?(context) click to toggle source
# File lib/aws-sdk-core/rpc_v2/content_type_handler.rb, line 42
def empty_input_structure?(context)
  context.operation.input.shape.struct_class == EmptyStructure
end
eventstream_input?(context) click to toggle source
# File lib/aws-sdk-core/rpc_v2/content_type_handler.rb, line 28
def eventstream_input?(context)
  context.operation.input.shape.members.each do |_, ref|
    return true if ref.eventstream
  end
  false
end
eventstream_output?(context) click to toggle source
# File lib/aws-sdk-core/rpc_v2/content_type_handler.rb, line 35
def eventstream_output?(context)
  context.operation.output.shape.members.each do |_, ref|
    return true if ref.eventstream
  end
  false
end