lib/geocoder/lookups/base.rb in geocoder-1.2.9 vs lib/geocoder/lookups/base.rb in geocoder-1.2.10

- old
+ new

@@ -269,23 +269,23 @@ ## # Make an HTTP(S) request to a geocoding API and # return the response object. # def make_api_request(query) - timeout(configuration.timeout) do - uri = URI.parse(query_url(query)) - Geocoder.log(:debug, "Geocoder: HTTP request being made for #{uri.to_s}") - http_client.start(uri.host, uri.port, use_ssl: use_ssl?) do |client| - req = Net::HTTP::Get.new(uri.request_uri, configuration.http_headers) - if configuration.basic_auth[:user] and configuration.basic_auth[:password] - req.basic_auth( - configuration.basic_auth[:user], - configuration.basic_auth[:password] - ) - end - client.request(req) + uri = URI.parse(query_url(query)) + Geocoder.log(:debug, "Geocoder: HTTP request being made for #{uri.to_s}") + http_client.start(uri.host, uri.port, use_ssl: use_ssl?, open_timeout: configuration.timeout, read_timeout: configuration.timeout) do |client| + req = Net::HTTP::Get.new(uri.request_uri, configuration.http_headers) + if configuration.basic_auth[:user] and configuration.basic_auth[:password] + req.basic_auth( + configuration.basic_auth[:user], + configuration.basic_auth[:password] + ) end + client.request(req) end + rescue Net::OpenTimeout, Net::ReadTimeout + raise Geocoder::LookupTimeout end def use_ssl? if supported_protocols == [:https] true