server/handlerwrappers/default.rb in cpee-1.5.3 vs server/handlerwrappers/default.rb in cpee-1.5.4
- old
+ new
@@ -67,12 +67,18 @@
callback = Digest::MD5.hexdigest(Kernel::rand().to_s)
(parameters[:arguments] || []).each do |s|
if s.respond_to?(:mimetype)
params << Riddl::Parameter::Complex.new(s.name.to_s,v.mimetype,v.value)
else
- if s.name.to_s =~ /__$/
- params << Riddl::Parameter::Simple.new(s.name.to_s.chop.chop,CPEE::ValueHelper::generate(s.value),:query)
+ if s.name.to_s =~ /^__Q_/
+ params << Riddl::Parameter::Simple.new(s.name.to_s.sub(/^__Q_/,''),CPEE::ValueHelper::generate(s.value),:query)
+ elsif s.name.to_s =~ /^__B_/
+ params << Riddl::Parameter::Simple.new(s.name.to_s.sub(/^__B_/,''),CPEE::ValueHelper::generate(s.value),:body)
+ elsif s.name.to_s =~ /^__H_/
+ params << Riddl::Header.new(s.name.to_s.sub(/^__H_/,''),CPEE::ValueHelper::generate(s.value))
+ elsif s.name.to_s =~ /^__C_/
+ params << Riddl::Parameter::Complex.new(s.name.to_s.sub(/^__C_/,''),*CPEE::ValueHelper::generate(s.value).split(';',2))
else
params << Riddl::Parameter::Simple.new(s.name.to_s,CPEE::ValueHelper::generate(s.value))
end
end
end
@@ -97,10 +103,12 @@
@controller.callbacks[callback] = CPEE::Callback.new("callback activity: #{@handler_position}",self,:callback,nil,nil,:http)
@handler_passthrough = callback
status, result, headers = client.request type => params
if status < 200 || status >= 300
- callback([ Riddl::Parameter::Complex.new('error','application/json',StringIO.new(JSON::generate({ 'status' => status, 'error' => result[0].value.read }))) ], 'CPEE_SALVAGE' => true)
+ c = result[0]&.value
+ c = c.read if c.respond_to? :read
+ callback([ Riddl::Parameter::Complex.new('error','application/json',StringIO.new(JSON::generate({ 'status' => status, 'error' => c }))) ], 'CPEE_SALVAGE' => true)
else
if headers['CPEE_INSTANTIATION']
@controller.notify("task/instantiation", :instance => @controller.instance, :label => @label, :instance_name => @controller.info, :instance_uuid => @controller.uuid, :activity => @handler_position, :endpoint => @handler_endpoint, :received => CPEE::ValueHelper.parse(headers['CPEE_INSTANTIATION']), :timestamp => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%L%:z"), :attributes => @controller.attributes_translated)
end
if headers['CPEE_CALLBACK'] && headers['CPEE_CALLBACK'] == 'true' && result.any?