incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1072038 - /incubator/deltacloud/trunk/client/lib/deltacloud.rb
Date Fri, 18 Feb 2011 16:13:48 GMT
Author: mfojtik
Date: Fri Feb 18 16:13:47 2011
New Revision: 1072038

URL: http://svn.apache.org/viewvc?rev=1072038&view=rev
Log:
:open_timeout and :timeout can be specified, but default to
10 and 45 seconds, respectively. If exceeded, a RestClient::RequestTimeout
exception is raised. (Thanks Matt Wagner)

Modified:
    incubator/deltacloud/trunk/client/lib/deltacloud.rb

Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=1072038&r1=1072037&r2=1072038&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Fri Feb 18 16:13:47 2011
@@ -315,14 +315,17 @@ module DeltaCloud
         :method => (args[0] || 'get').to_sym,
         :path => (args[1]=~/^http/) ? args[1] : "#{api_uri.to_s}#{args[1]}",
         :query_args => args[2] || {},
-        :form_data => args[3] || {}
+        :form_data => args[3] || {},
+        :timeout => args[4] || 45,
+        :open_timeout => args[5] || 10
       }
       if conf[:query_args] != {}
         conf[:path] += '?' + URI.escape(conf[:query_args].collect{ |key, value| "#{key}=#{value}"
}.join('&')).to_s
       end
 
       if conf[:method].eql?(:post)
-        RestClient.send(:post, conf[:path], conf[:form_data], default_headers.merge(extended_headers))
do |response, request, block|
+        resource = RestClient::Resource.new(conf[:path], :open_timeout => conf[:open_timeout],
:timeout => conf[:timeout])
+        resource.send(:post, conf[:form_data], default_headers.merge(extended_headers)) do
|response, request, block|
           handle_backend_error(response) if response.code.eql?(500)
           if response.respond_to?('body')
             yield response.body if block_given?
@@ -331,7 +334,8 @@ module DeltaCloud
           end
         end
       else
-        RestClient.send(conf[:method], conf[:path], default_headers.merge(extended_headers))
do |response, request, block|
+        resource = RestClient::Resource.new(conf[:path], :open_timeout => conf[:open_timeout],
:timeout => conf[:timeout])
+        resource.send(conf[:method], default_headers.merge(extended_headers)) do |response,
request, block|
           handle_backend_error(response) if response.code.eql?(500)
           if conf[:method].eql?(:get) and [301, 302, 307].include? response.code
             response.follow_redirection(request) do |response, request, block|



Mime
View raw message