Skip to content

Commit

Permalink
set open/read timeout by options.
Browse files Browse the repository at this point in the history
  • Loading branch information
kei-s committed Mar 6, 2011
1 parent b2530df commit 8267d4c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion oa-oauth/lib/omniauth/strategies/oauth.rb
Expand Up @@ -14,7 +14,10 @@ def initialize(app, name, consumer_key = nil, consumer_secret = nil, consumer_op
end

def consumer
::OAuth::Consumer.new(consumer_key, consumer_secret, consumer_options.merge(options[:client_options] || options[:consumer_options] || {}))
consumer = ::OAuth::Consumer.new(consumer_key, consumer_secret, consumer_options.merge(options[:client_options] || options[:consumer_options] || {}))
consumer.http.open_timeout = options[:open_timeout] if options[:open_timeout]
consumer.http.read_timeout = options[:read_timeout] if options[:read_timeout]
consumer
end

attr_reader :name
Expand All @@ -33,6 +36,8 @@ def request_phase
end

r.finish
rescue ::Timeout::Error => e
fail!(:timeout_error_in_request_phase, e)
end

def callback_phase
Expand All @@ -47,6 +52,8 @@ def callback_phase

@access_token = request_token.get_access_token(opts)
super
rescue ::Timeout::Error => e
fail!(:timeout_error_in_callback_phase, e)
rescue ::Net::HTTPFatalError => e
fail!(:service_unavailable, e)
rescue ::OAuth::Unauthorized => e
Expand Down

0 comments on commit 8267d4c

Please sign in to comment.