summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMartin Gütlein <martin.guetlein@gmail.com>2010-04-19 17:59:49 +0200
committerMartin Gütlein <martin.guetlein@gmail.com>2010-04-19 17:59:49 +0200
commitf051bd1f965a7d487e630c5df440998b8e9acdd3 (patch)
treed642271c3b286e11232de41f9db1786a276f2f16 /lib
parent429a21a3aed47afa63a1c6963d41efc4322a3e5d (diff)
make sure that result is a string!
Diffstat (limited to 'lib')
-rw-r--r--lib/rest_client_wrapper.rb50
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/rest_client_wrapper.rb b/lib/rest_client_wrapper.rb
index a70da98..53cdf06 100644
--- a/lib/rest_client_wrapper.rb
+++ b/lib/rest_client_wrapper.rb
@@ -74,36 +74,36 @@ module OpenTox
payload.each{ |k,v| payload.delete(k) if v==nil } if payload #remove keys with empty values, as this can cause problems
unless curl_hack
if payload
- result = RestClient.send(rest_call, uri, payload, headers)
+ result = RestClient.send(rest_call, uri, payload, headers).to_s
else
- result = RestClient.send(rest_call, uri, headers)
+ result = RestClient.send(rest_call, uri, headers).to_s
end
else
- result = ""
- cmd = " curl -v -X "+rest_call.upcase+" "+payload.collect{|k,v| "-d "+k.to_s+"='"+v.to_s+"' "}.join("")+" "+uri.to_s
- LOGGER.debug "CURL HACK: "+cmd
- IO.popen(cmd+" 2> /dev/null") do |f|
- while line = f.gets
- result += line
- end
- end
- result.chomp!("\n")
- LOGGER.debug "CURL -> "+result.to_s
- raise "curl call failed "+result if $?!=0
- #raise "STOP "+result
- end
+ result = ""
+ cmd = " curl -v -X "+rest_call.upcase+" "+payload.collect{|k,v| "-d "+k.to_s+"='"+v.to_s+"' "}.join("")+" "+uri.to_s
+ LOGGER.debug "CURL HACK: "+cmd
+ IO.popen(cmd+" 2> /dev/null") do |f|
+ while line = f.gets
+ result += line
+ end
+ end
+ result.chomp!("\n")
+ LOGGER.debug "CURL -> "+result.to_s
+ raise "curl call failed "+result if $?!=0
+ #raise "STOP "+result
+ end
- if wait_for_task
- if result.to_s =~ /ambit.*task|tu-muenchen.*task/
- result = redirect_task(result)
- elsif Utils.task_uri?(result)
- task = OpenTox::Task.find(result)
- task.wait_for_completion
- raise task.description if task.failed?
- result = task.resource
+ if wait_for_task
+ if result.to_s =~ /ambit.*task|tu-muenchen.*task/
+ result = redirect_task(result)
+ elsif Utils.task_uri?(result)
+ task = OpenTox::Task.find(result)
+ task.wait_for_completion
+ raise task.description if task.failed?
+ result = task.resource
+ end
end
- end
- return result
+ return result
rescue RestClient::RequestFailed => ex
do_halt ex.http_code,ex.http_body,uri,payload,headers