diff options
author | rautenberg <rautenberg@in-silico.ch> | 2013-02-07 11:55:58 +0100 |
---|---|---|
committer | rautenberg <rautenberg@in-silico.ch> | 2013-02-07 11:55:58 +0100 |
commit | 2d7909789e3a4ee3c669125fb1f09fe3b4577de8 (patch) | |
tree | c5b448618d69e8c13b12aa9f0b9588a93c3cfe02 /lib/rest-client-wrapper.rb | |
parent | f1a6d9f9d5bc73d757e0864d998c95f10ebeecbb (diff) | |
parent | cadc92f526a04dd270134bade08d053f4b099923 (diff) |
Merge branch 'development' of github.com:opentox/opentox-client into development
Diffstat (limited to 'lib/rest-client-wrapper.rb')
-rw-r--r-- | lib/rest-client-wrapper.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/rest-client-wrapper.rb b/lib/rest-client-wrapper.rb index 79a65d9..f3c56c8 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) |