Class: Aws::Rest::ContentTypeHandler Private

Inherits:
Seahorse::Client::Handler show all
Defined in:
lib/aws-sdk-core/rest/content_type_handler.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

NOTE: headers could be already populated if specified on input shape

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Handler

#handler

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Handler

#initialize, #inspect

Constructor Details

This class inherits a constructor from Seahorse::Client::Handler

Instance Method Details

#call(context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/aws-sdk-core/rest/content_type_handler.rb', line 7

def call(context)
  if eventstream?(context)
    context.http_request.headers['Content-Type'] ||=
      'application/vnd.amazon.eventstream'
  elsif (payload = context.operation.input[:payload_member])
    case payload.shape
    when Seahorse::Model::Shapes::BlobShape
      context.http_request.headers['Content-Type'] ||=
        'application/octet-stream'
    when Seahorse::Model::Shapes::StringShape
      context.http_request.headers['Content-Type'] ||=
        'text/plain'
    else
      apply_default_content_type(context)
    end
  elsif (body = context.http_request.body) &&
        (!body.respond_to?(:size) || non_empty_body?(body))
    apply_default_content_type(context)
  end

  @handler.call(context)
end