From cbc04c1c2b48ea27772572db19ff7585c3412868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Audet?= Date: Mon, 25 Feb 2013 20:42:41 +0100 Subject: [PATCH] Added support for a proxy throught options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaƫl Audet --- lib/logglier/client/http/sync.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/logglier/client/http/sync.rb b/lib/logglier/client/http/sync.rb index 5884377..9143f8b 100644 --- a/lib/logglier/client/http/sync.rb +++ b/lib/logglier/client/http/sync.rb @@ -32,6 +32,10 @@ def initialize(input_uri, opts={}) @open_timeout = opts[:open_timeout] || 5 @failsafe = opts[:failsafe] || $stderr @format = opts[:format] ? opts[:format].to_sym : nil + @proxy_addr = opts[:proxy_addr] + @proxy_port = opts[:proxy_port] + @proxy_user = opts[:proxy_user] + @proxy_password = opts[:proxy_password] @headers = {} if @format == :json @headers['Content-Type'] = 'application/json' @@ -68,7 +72,8 @@ def deliver(message) private def connect! - @http = Net::HTTP.new(@input_uri.host, @input_uri.port) + @http_class = Net::HTTP::Proxy(@proxy_addr, @proxy_port, @proxy_user, @proxy_user) + @http = @http_class.new(@input_uri.host, @input_uri.port) if @input_uri.scheme == 'https' @http.use_ssl = true