From 499a3f24f0defd56a0e01a24af45e4e68114d840 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 23 Oct 2012 12:38:37 +0200 Subject: [PATCH] appmarket: Add proxy support for appmarket client --- market/client/lib/appmarket_client.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/market/client/lib/appmarket_client.rb b/market/client/lib/appmarket_client.rb index f9fa1873f0..b58a3378bb 100644 --- a/market/client/lib/appmarket_client.rb +++ b/market/client/lib/appmarket_client.rb @@ -26,29 +26,38 @@ module Market @uri = URI.parse(url) @user_agent = "OpenNebula #{CloudClient::VERSION} (#{user_agent})" + + @host = nil + @port = nil + + if ENV['http_proxy'] + uri_proxy = URI.parse(ENV['http_proxy']) + @host = uri_proxy.host + @port = uri_proxy.port + end end def get(path) - req = Net::HTTP::Get.new(path) + req = Net::HTTP::Proxy(@host, @port)::Get.new(path) do_request(req) end def delete(path) - req = Net::HTTP::Delete.new(path) + req = Net::HTTP::Proxy(@host, @port)::Delete.new(path) do_request(req) end def post(path, body) - req = Net::HTTP::Post.new(path) + req = Net::HTTP::Proxy(@host, @port)::Post.new(path) req.body = body do_request(req) end def put(path, body) - req = Net::HTTP::Put.new(path) + req = Net::HTTP::Proxy(@host, @port)::Put.new(path) req.body = body do_request(req)