diff --git a/lib/right_http_connection.rb b/lib/right_http_connection.rb index dab8c09..1992040 100644 --- a/lib/right_http_connection.rb +++ b/lib/right_http_connection.rb @@ -278,6 +278,20 @@ def start(request_params) @logger.info("Opening new #{@protocol.upcase} connection to #@server:#@port") @http = Net::HTTP.new(@server, @port) + + # Support HTTP and HTTPS proxies + if @protocol == "https" && ENV['https_proxy'] + proxy_host, proxy_port = ENV['https_proxy'].gsub(/^http(s?):\/\//, '').split(':') + @http = Net::HTTP::Proxy(proxy_host, proxy_port).new(@server, @port) + @logger.info("Using #{proxy_host}:#{proxy_port} proxy for connection") + end + + if @protocol == "http" && ENV['http_proxy'] + proxy_host, proxy_port = ENV['http_proxy'].gsub(/^http(s?):\/\//, '').split(':') + @http = Net::HTTP::Proxy(proxy_host, proxy_port).new(@server, @port) + @logger.info("Using #{proxy_host}:#{proxy_port} proxy for connection") + end + @http.open_timeout = @params[:http_connection_open_timeout] @http.read_timeout = @params[:http_connection_read_timeout]