Skip to content

Commit

Permalink
Use :bind instead of :socket_local to set local socket
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed May 7, 2012
1 parent b0c6cbd commit 8fe63e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions lib/faraday/adapter/httpclient.rb
Expand Up @@ -15,8 +15,8 @@ def call(env)
configure_proxy proxy
end

if sock = req[:socket_local]
configure_local_socket sock
if bind = req[:bind]
configure_socket bind
end

configure_timeouts req
Expand All @@ -41,9 +41,9 @@ def call(env)
raise Faraday::Error::TimeoutError, $!
end

def configure_local_socket(sock)
client.socket_local.host = sock[:host]
client.socket_local.port = sock[:port]
def configure_socket(bind)
client.socket_local.host = bind[:host]
client.socket_local.port = bind[:port]
end

def configure_proxy(proxy)
Expand Down
13 changes: 6 additions & 7 deletions test/adapters/httpclient_test.rb
Expand Up @@ -5,13 +5,12 @@ class HttpclientTest < Faraday::TestCase

def adapter() :httpclient end

Integration.apply(self, :NonParallel)

def test_local_socket
adapter = Faraday::Adapter::HTTPClient.new
adapter.configure_local_socket({ :host => 'foo' })
assert_equal 'foo', adapter.client.socket_local.host
assert_nil adapter.client.socket_local.port
Integration.apply(self, :NonParallel) do
def test_binds_local_socket
host = '1.2.3.4'
conn = create_connection :request => { :bind => { :host => host } }
assert_equal host, conn.options[:bind][:host]
end
end
end
end

0 comments on commit 8fe63e1

Please sign in to comment.