Skip to content
Snippets Groups Projects
Commit 9f4cea65 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge pull request #216 from robotmay/master

Add support for custom HTTP request headers
parents f5cbf275 35488487
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,9 @@ module Geocoder ...@@ -14,6 +14,9 @@ module Geocoder
# use HTTPS for lookup requests? (if supported) # use HTTPS for lookup requests? (if supported)
[:use_https, false], [:use_https, false],
# optionally supply the headers for the HTTP request, e.g. User-Agent
[:request_headers, {}],
# HTTP proxy server (user:pass@host:port) # HTTP proxy server (user:pass@host:port)
[:http_proxy, nil], [:http_proxy, nil],
......
...@@ -149,7 +149,7 @@ module Geocoder ...@@ -149,7 +149,7 @@ module Geocoder
unless cache and body = cache[url] unless cache and body = cache[url]
client = http_client.new(uri.host, uri.port) client = http_client.new(uri.host, uri.port)
client.use_ssl = true if Geocoder::Configuration.use_https client.use_ssl = true if Geocoder::Configuration.use_https
response = client.get(uri.request_uri) response = client.get(uri.request_uri, Geocoder::Configuration.request_headers)
body = response.body body = response.body
if cache and (200..399).include?(response.code.to_i) if cache and (200..399).include?(response.code.to_i)
cache[url] = body cache[url] = body
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment