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}"
data = {}
begin
conn = Faraday.new( :url => host )
conn = Faraday.new( :url => host, :options => { :open_timeout => 2, :timeout => 5 } )
response = conn.get url
data = JSON.parse( response.body )
Cache.write( cache_key, data, { :expires_in => 90.days } )