class Aws::Plugins::TransferEncoding::Handler

@api private

Public Instance Methods

call(context) click to toggle source
# File lib/aws-sdk-core/plugins/transfer_encoding.rb, line 14
def call(context)
  if streaming?(context.operation.input)
    # If it's an IO object and not a File / String / String IO
    unless context.http_request.body.respond_to?(:size)
      if requires_length?(context.operation.input)
        # if size of the IO is not available but required
        raise Aws::Errors::MissingContentLength
      elsif unsigned_payload?(context.operation)
        context.http_request.headers['Transfer-Encoding'] = 'chunked'
      end
    end
  end

  @handler.call(context)
end

Private Instance Methods

requires_length?(ref) click to toggle source
# File lib/aws-sdk-core/plugins/transfer_encoding.rb, line 45
def requires_length?(ref)
  if (payload = ref[:payload_member])
    payload['requiresLength'] || payload.shape['requiresLength']
  else
    false
  end
end
streaming?(ref) click to toggle source
# File lib/aws-sdk-core/plugins/transfer_encoding.rb, line 32
def streaming?(ref)
  if (payload = ref[:payload_member])
    payload['streaming'] || payload.shape['streaming']
  else
    false
  end
end
unsigned_payload?(operation) click to toggle source
# File lib/aws-sdk-core/plugins/transfer_encoding.rb, line 40
def unsigned_payload?(operation)
  operation['unsignedPayload'] ||
    operation['authtype'] == 'v4-unsigned-body'
end