diff --git a/lib/geocoder/lookups/base.rb b/lib/geocoder/lookups/base.rb index 3e9ec67724f6a1802632a611e8d5b953c78e9f93..467f0b9c395d31cf18b316dc914191ceea0e0f24 100644 --- a/lib/geocoder/lookups/base.rb +++ b/lib/geocoder/lookups/base.rb @@ -227,15 +227,13 @@ module Geocoder def make_api_request(query) timeout(configuration.timeout) do uri = URI.parse(query_url(query)) - # client = http_client.new(uri.host, uri.port) - # client.use_ssl = true if configuration.use_https - # client.get(uri.request_uri, configuration.http_headers) + args = [uri.host, uri.port] + args = args.push(uri.user, uri.password) unless uri.user.nil? or uri.password.nil? + opts = {} + opts[:use_ssl] = true if configuration.use_https - http_client.start(uri.host, uri.port) do |client| - client.use_ssl = true if configuration.use_https - req = Net::HTTP::Get.new(uri.request_uri, configuration.http_headers) - req.basic_auth(uri.user, uri.password) if uri.user and uri.password - client.request(req) + http_client.start(*args, opts) do |client| + resp = client.get(uri.request_uri, configuration.http_headers) end end end