appmarket: Add proxy support for appmarket client

This commit is contained in:
Daniel Molina committed 2012-10-23 12:38:37 +02:00
1 parent a1987c3a3f
commit 499a3f24f0
1 file changed
+13 -4
+13 -4
View File
@@ -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)