From 55cd606b8a278054e18a377e29b9043434ef673c Mon Sep 17 00:00:00 2001 From: Peter Bakkum Date: Fri, 3 May 2013 15:20:58 -0700 Subject: [PATCH] added timeout option --- lib/redphone/helpers.rb | 2 ++ lib/redphone/pagerduty.rb | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/redphone/helpers.rb b/lib/redphone/helpers.rb index 9db41f8..33d2e71 100644 --- a/lib/redphone/helpers.rb +++ b/lib/redphone/helpers.rb @@ -15,6 +15,8 @@ def http_request(options={}) parameters = options[:parameters] || Hash.new body = options[:body] http = Net::HTTP.new(uri.host, uri.port) + http.open_timeout = options[:timeout] if options[:timeout] + http.read_timeout = options[:timeout] if options[:timeout] if options[:ssl] == true http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE diff --git a/lib/redphone/pagerduty.rb b/lib/redphone/pagerduty.rb index 0c72019..ef1fbfb 100644 --- a/lib/redphone/pagerduty.rb +++ b/lib/redphone/pagerduty.rb @@ -59,6 +59,7 @@ def incidents(options={}) :password => @password, :ssl => true, :uri => "https://#{@subdomain}.pagerduty.com/api/v1/incidents", + :timeout => options[:timeout], :parameters => options ) JSON.parse(response.body) @@ -70,6 +71,7 @@ def incidents_count(options={}) :password => @password, :ssl => true, :uri => "https://#{@subdomain}.pagerduty.com/api/v1/incidents/count", + :timeout => options[:timeout], :parameters => options ) JSON.parse(response.body) @@ -82,6 +84,7 @@ def schedules(options={}) :password => @password, :ssl => true, :uri => "https://#{@subdomain}.pagerduty.com/api/v1/schedules/#{options[:schedule_id]}/entries", + :timeout => options[:timeout], :parameters => options ) JSON.parse(response.body)