From d68d4c77f68f47e80719211b8ccb1ffe99028114 Mon Sep 17 00:00:00 2001
From: Michal Fojtik <mfojtik@redhat.com>
Date: Fri, 3 Jun 2011 14:03:31 +0200
Subject: [PATCH 1/2] Added support for proxy environment variables (http_proxy
 and https_proxy)

---
 lib/right_http_connection.rb | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/right_http_connection.rb b/lib/right_http_connection.rb
index dab8c09..71c590d 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 == "https" && 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]
 

From 1c0d3fa0b94b8401da1f30c42b03859e59581e86 Mon Sep 17 00:00:00 2001
From: Michal Fojtik <mfojtik@redhat.com>
Date: Fri, 3 Jun 2011 14:11:24 +0200
Subject: [PATCH 2/2] Fixed typo in https

---
 lib/right_http_connection.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/right_http_connection.rb b/lib/right_http_connection.rb
index 71c590d..1992040 100644
--- a/lib/right_http_connection.rb
+++ b/lib/right_http_connection.rb
@@ -286,7 +286,7 @@ def start(request_params)
         @logger.info("Using #{proxy_host}:#{proxy_port} proxy for connection")
       end
 
-      if @protocol == "https" && ENV['http_proxy']
+      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")