lib/ecb/exchange/xml_feed.rb in ecb_exchange-0.2.0 vs lib/ecb/exchange/xml_feed.rb in ecb_exchange-0.2.1
- old
+ new
@@ -6,11 +6,11 @@
module ECB
module Exchange
class XMLFeed
- NINETY_DAY_ENDPOINT = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml".freeze
+ NINETY_DAY_ENDPOINT = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml".freeze
@endpoint = URI(NINETY_DAY_ENDPOINT)
# allow a configurable endpoint
class << self
attr_reader :endpoint
@@ -42,10 +42,12 @@
end
daily_rates
end
def self.get_xml
- resp = Net::HTTP.new(endpoint.host, endpoint.port).get(endpoint.path)
+ http = Net::HTTP.new(endpoint.host, endpoint.port)
+ http.use_ssl = endpoint.scheme === "https"
+ resp = http.get(endpoint.path)
if resp.code == "200"
resp.body
else
raise ResponseError.new(endpoint, "status: #{resp.code}")
end