diff --git a/lib/geocoder/configuration.rb b/lib/geocoder/configuration.rb
index 743920ba17f43c21cfabefefb8b423ae2bc80f9a..500ac9c91f73c3d60ad0161578c8b008d55e5385 100644
--- a/lib/geocoder/configuration.rb
+++ b/lib/geocoder/configuration.rb
@@ -15,10 +15,10 @@ module Geocoder
# use HTTPS for lookup requests? (if supported)
[:use_https, false],
- # URL of HTTP proxy
+ # HTTP proxy server (not including "http://")
[:http_proxy, nil],
- # URL of HTTPS proxy
+ # HTTPS proxy server (not including "https://")
[:https_proxy, nil],
# API key for geocoding service
diff --git a/lib/geocoder/lookups/base.rb b/lib/geocoder/lookups/base.rb
index a6cf96d2a5afacfe77b333c865051be1eedb2c5f..497f73ed85f8448f3da3bff129b7664265faec0b 100644
--- a/lib/geocoder/lookups/base.rb
+++ b/lib/geocoder/lookups/base.rb
@@ -58,14 +58,15 @@ module Geocoder
# Object used to make HTTP requests.
#
def http_client
- secure = Geocoder::Configuration.use_https
- proxy_name = "http#{'s' if secure}_proxy"
- if proxy_url = Geocoder::Configuration.send(proxy_name)
+ protocol = "http#{'s' if Geocoder::Configuration.use_https}"
+ proxy_name = "#{protocol}_proxy"
+ if proxy = Geocoder::Configuration.send(proxy_name)
+ proxy_url = protocol + '://' + proxy
begin
uri = URI.parse(proxy_url)
rescue URI::InvalidURIError
raise ConfigurationError,
- "Error parsing HTTP#{'S' if secure} proxy URL: '#{proxy_url}'"
+ "Error parsing #{protocol.upcase} proxy URL: '#{proxy_url}'"
end
Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password)
else
diff --git a/test/geocoder_test.rb b/test/geocoder_test.rb
index 416867d921cadec401c51200ba31717966626f04..67bc298ed36379bbc7180351432b1b2fc1a5d0d4 100644
--- a/test/geocoder_test.rb
+++ b/test/geocoder_test.rb
@@ -21,7 +21,7 @@ class GeocoderTest < Test::Unit::TestCase
# --- sanity checks ---
def test_uses_proxy_when_specified
- Geocoder::Configuration.http_proxy = 'http://localhost'
+ Geocoder::Configuration.http_proxy = 'localhost'
lookup = Geocoder::Lookup::Google.new
assert lookup.send(:http_client).proxy_class?
end