Permalink
Browse files

Use :bind instead of :socket_local to set local socket

  • Loading branch information...
1 parent b0c6cbd commit 8fe63e1651c614c859b1f76af7b4c131ef4e44f4 Hakan Ensari committed May 7, 2012
Showing with 11 additions and 12 deletions.
  1. +5 −5 lib/faraday/adapter/httpclient.rb
  2. +6 −7 test/adapters/httpclient_test.rb
@@ -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
@@ -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)
@@ -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.