Added timeout options for Faraday.

This commit is contained in:
Martin Edenhofer 2014-12-18 08:40:38 +01:00
parent d6ebe079e6
commit d7dd63ae4a

View file

@ -16,7 +16,7 @@ class GeoIp::Freegeoip
url = "/json/#{CGI::escape address}" url = "/json/#{CGI::escape address}"
data = {} data = {}
begin begin
conn = Faraday.new( :url => host ) conn = Faraday.new( :url => host, :options => { :open_timeout => 2, :timeout => 5 } )
response = conn.get url response = conn.get url
data = JSON.parse( response.body ) data = JSON.parse( response.body )
Cache.write( cache_key, data, { :expires_in => 90.days } ) Cache.write( cache_key, data, { :expires_in => 90.days } )