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

feature #1433: http proxy support for CloudClient.rb, contributed by Laurent Grawet

This commit is contained in:
Daniel Molina 2012-10-01 17:28:15 +02:00
parent 2685dc96d2
commit c403a5b48e
2 changed files with 5 additions and 4 deletions

View File

@ -83,7 +83,8 @@ module CloudClient
# is set if needed.
# #########################################################################
def self.http_start(url, timeout, &block)
http = Net::HTTP.new(url.host, url.port)
proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new
http = Net::HTTP::Proxy(proxy.host, proxy.port).new(url.host, url.port)
if timeout
http.read_timeout = timeout.to_i

View File

@ -27,16 +27,16 @@ module Market
@uri = URI.parse(url)
@user_agent = "OpenNebula #{CloudClient::VERSION} (#{user_agent})"
@proxy = ENV['http_proxy'] ? URI.parse(ENV['http_proxy']) : OpenStruct.new
end
def get(path)
req = Net::HTTP::Get.new(path)
req = Net::HTTP::Proxy(@proxy.host, @proxy.port)::Get.new(path)
do_request(req)
end
def post(path, body)
req = Net::HTTP::Post.new(path)
req = Net::HTTP::Proxy(@proxy.host, @proxy.port)::Post.new(path)
req.body = body
do_request(req)