1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Fix proxy code for market monitor in ruby 1.9.3

This commit is contained in:
Javi Fontan 2016-09-13 17:02:44 +02:00
parent 9e5c895cbf
commit d9df87c746

View File

@ -33,12 +33,25 @@ class OneMarket
end
def get(path)
# Get proxy params (needed for ruby 1.9.3)
http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
if http_proxy
p_uri = URI(http_proxy)
p_host = p_uri.host
p_port = p_uri.port
else
p_host = nil
p_port = nil
end
uri = URI(@url + path)
req = Net::HTTP::Get.new(uri.request_uri)
req['User-Agent'] = @agent
response = Net::HTTP.start(uri.hostname, uri.port, :ENV) {|http|
response = Net::HTTP.start(uri.hostname, uri.port, p_host, p_port) {|http|
http.request(req)
}