Skip to content

Commit

Permalink
Merge pull request #152 from downapp/master
Browse files Browse the repository at this point in the history
add proxy to config for httpclient calls
  • Loading branch information
maxdemarzi committed Feb 28, 2014
2 parents d9e9e89 + 712400e commit 0b01621
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/neography/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -51,6 +53,7 @@ def set_defaults
@password = nil
@parser = MultiJsonParser
@max_execution_time = 6000
@proxy = nil
end

end
Expand Down
6 changes: 4 additions & 2 deletions lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
5 changes: 4 additions & 1 deletion spec/unit/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down

0 comments on commit 0b01621

Please sign in to comment.