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 1/2] 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 }

From 712400e54e4d59436cc838f326da5d1b58810946 Mon Sep 17 00:00:00 2001
From: Colin Hodge <c@bangwithfriends.com>
Date: Tue, 25 Feb 2014 03:38:02 -0800
Subject: [PATCH 2/2] fix config tests for proxy addition

---
 spec/unit/config_spec.rb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb
index 418f554..a1bb5e6 100644
--- a/spec/unit/config_spec.rb
+++ b/spec/unit/config_spec.rb
@@ -23,6 +23,8 @@ module Neography
       its(:password)           { should == nil }
       its(:parser)             { should == MultiJsonParser}
       its(:max_execution_time) { should == 6000 }
+      its(:proxy)              { should == nil }
+
 
       it "has a hash representation" do
         expected_hash = {
@@ -41,7 +43,8 @@ module Neography
           :username           => nil,
           :password           => nil,
           :parser             => MultiJsonParser,
-          :max_execution_time => 6000
+          :max_execution_time => 6000,
+          :proxy              => nil
         }
         config.to_hash.should == expected_hash
       end