summaryrefslogtreecommitdiff
path: root/lib/rest-client-wrapper.rb
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2013-02-04 14:07:28 +0100
committermguetlein <martin.guetlein@gmail.com>2013-02-04 14:07:28 +0100
commit54b833546cea44e03eca3183ad4a37b9f30651a1 (patch)
treefb240014170efdf4f19ee2d15c6217bc7b128ffc /lib/rest-client-wrapper.rb
parent8a374b38d1e8b727f365b6ce5edf5424eb1a0c7d (diff)
add validation, some debug messages, small adjustments
Diffstat (limited to 'lib/rest-client-wrapper.rb')
-rw-r--r--lib/rest-client-wrapper.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/rest-client-wrapper.rb b/lib/rest-client-wrapper.rb
index 1258339..0d1c56b 100644
--- a/lib/rest-client-wrapper.rb
+++ b/lib/rest-client-wrapper.rb
@@ -13,13 +13,13 @@ module OpenTox
# @return [RestClient::Response] REST call response
[:head,:get,:post,:put,:delete].each do |method|
- define_singleton_method method do |uri,payload={},headers={}|
+ define_singleton_method method do |uri,payload={},headers={},waiting_task=nil|
- # check input
+ # check input
+ bad_request_error "Headers are not a hash: #{headers.inspect}", uri unless headers==nil or headers.is_a?(Hash)
@subjectid = headers[:subjectid] ? headers[:subjectid] : nil
bad_request_error "Invalid URI: '#{uri}'", uri unless URI.valid? uri
#resource_not_found_error "URI '#{uri}' not found.", uri unless URI.accessible?(uri, @subjectid) unless URI.ssl?(uri)
- bad_request_error "Headers are not a hash: #{headers.inspect}", uri unless headers==nil or headers.is_a?(Hash)
# make sure that no header parameters are set in the payload
[:accept,:content_type,:subjectid].each do |header|
if defined? $aa || URI(uri).host == URI($aa[:uri]).host
@@ -36,6 +36,8 @@ module OpenTox
args[:payload] = payload
headers.each{ |k,v| headers.delete(k) if v==nil } if headers #remove keys with empty values, as this can cause problems
args[:headers] = headers
+
+ $logger.debug "POST #{uri} #{payload.inspect}" if method.to_s=="post" && payload.is_a?(Hash)
@request = RestClient::Request.new(args)
# ignore error codes from Task services (may return error codes >= 400 according to API, which causes exceptions in RestClient and RDF::Reader)