From 475c67539ef34afacb7f55fa5a5993416b1b785f Mon Sep 17 00:00:00 2001
From: Colin Hodge <c@bangwithfriends.com>
Date: Mon, 24 Feb 2014 19:39:19 -0800
Subject: [PATCH] add proxy to config for httpclient calls

---
 lib/neography/config.rb     | 7 +++++--
 lib/neography/connection.rb | 6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/neography/config.rb b/lib/neography/config.rb
index 86090bb..481599e 100644
--- a/lib/neography/config.rb
+++ b/lib/neography/config.rb
@@ -6,7 +6,8 @@ class Config
       :log_file, :log_enabled, :logger, :slow_log_threshold,
       :max_threads,
       :authentication, :username, :password,
-      :parser, :max_execution_time
+      :parser, :max_execution_time,
+      :proxy
 
     def initialize
       set_defaults
@@ -29,7 +30,8 @@ def to_hash
         :username           => @username,
         :password           => @password,
         :parser             => @parser,
-        :max_execution_time => @max_execution_time
+        :max_execution_time => @max_execution_time,
+        :proxy              => @proxy
       }
     end
 
@@ -51,6 +53,7 @@ def set_defaults
       @password           = nil
       @parser             = MultiJsonParser
       @max_execution_time = 6000
+      @proxy              = nil
       end
 
   end
diff --git a/lib/neography/connection.rb b/lib/neography/connection.rb
index 52cfffe..bdb1fe6 100644
--- a/lib/neography/connection.rb
+++ b/lib/neography/connection.rb
@@ -10,12 +10,13 @@ class Connection
       :log_file, :log_enabled, :logger, :slow_log_threshold,
       :max_threads,
       :authentication, :username, :password,
-      :parser, :client
+      :parser, :client,
+      :proxy
 
     def initialize(options = ENV['NEO4J_URL'] || {})
       config = merge_configuration(options)
       save_local_configuration(config)
-      @client = HTTPClient.new
+      @client = HTTPClient.new(config[:proxy])
       @client.send_timeout = 1200 # 10 minutes
       @client.receive_timeout = 1200
       authenticate
@@ -101,6 +102,7 @@ def save_local_configuration(config)
       @max_threads        = config[:max_threads]
       @parser             = config[:parser]
       @logger             = config[:logger]
+      @proxy              = config[:proxy]
 
       @max_execution_time = { 'max-execution-time' => config[:max_execution_time] }
       @user_agent     = { "User-Agent" => USER_AGENT }