diff options
author | Martin Gütlein <martin.guetlein@gmail.com> | 2010-04-23 14:45:48 +0200 |
---|---|---|
committer | Martin Gütlein <martin.guetlein@gmail.com> | 2010-04-23 14:45:48 +0200 |
commit | 08232976c35511086fe6787c6c8c098c63ef0818 (patch) | |
tree | a153cac4b42206d6e4ace0bb3a14f90cfdcc79bb /lib | |
parent | ad974c419a2efe4c0ceaa1f3e2346906b5783e52 (diff) |
minor fixes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rest_client_wrapper.rb | 5 | ||||
-rw-r--r-- | lib/task.rb | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/rest_client_wrapper.rb b/lib/rest_client_wrapper.rb index 5a6362b..86ee890 100644 --- a/lib/rest_client_wrapper.rb +++ b/lib/rest_client_wrapper.rb @@ -85,6 +85,7 @@ module OpenTox do_halt 400,"uri is null",uri,headers,payload unless uri do_halt 400,"not a uri",uri,headers,payload unless Utils.is_uri?(uri) do_halt 400,"headers are no hash",uri,headers,payload unless headers==nil or headers.is_a?(Hash) + do_halt 400,"nil headers for post not allowed, use {}",uri,headers,payload if rest_call=="post" and headers==nil headers.each{ |k,v| headers.delete(k) if v==nil } if headers #remove keys with empty values, as this can cause problems begin @@ -131,6 +132,7 @@ module OpenTox task.wait_for_completion raise task.description if task.error? res = WrapperResult.new(task.resultURI) + LOGGER.debug "task resultURI "+res.to_s res.content_type = "text/uri-list" end return res @@ -140,7 +142,8 @@ module OpenTox rescue RestClient::RequestTimeout => ex do_halt 408,ex.message,uri,headers,payload rescue => ex - #raise ex.message+" uri: "+uri.to_s + #raise ex + #raise "'"+ex.message+"' uri: "+uri.to_s begin code = ex.http_code msg = ex.http_body diff --git a/lib/task.rb b/lib/task.rb index dee8a86..99d8f13 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -14,7 +14,7 @@ module OpenTox public def self.create - task_uri = RestClientWrapper.post(@@config[:services]["opentox-task"], nil, nil, false).to_s + task_uri = RestClientWrapper.post(@@config[:services]["opentox-task"], {}, nil, false).to_s Task.find(task_uri.chomp) end @@ -116,7 +116,6 @@ module OpenTox begin result = catch(:halt) do yield task - LOGGER.debug "Task #{task.uri} done #{Time.now}" end if result && result.is_a?(Array) && result.size==2 && result[0]>202 # halted while executing task @@ -124,6 +123,7 @@ module OpenTox task.error(result[1]) throw :halt,result end + LOGGER.debug "Task #{task.uri} done #{Time.now} -> "+result.to_s task.completed(result) rescue => ex #raise ex |