Add bind option to Typhoeus [#154]

This commit is contained in:
Ezekiel Templin 2012-05-03 13:25:41 -04:00
parent 884ca38b4a
commit d4d88a1de8
2 changed files with 13 additions and 1 deletions

View File

@ -40,6 +40,7 @@ module Faraday
configure_ssl req, env
configure_proxy req, env
configure_timeout req, env
configure_socket req, env
req.on_complete do |resp|
if resp.timed_out?
@ -88,6 +89,12 @@ module Faraday
req.connect_timeout = (env_req[:open_timeout] * 1000) if env_req[:open_timeout]
end
def configure_socket(req, env)
if bind = request_options(env)[:bind]
req.interface = bind[:host]
end
end
def request_options(env)
env[:request]
end

View File

@ -10,5 +10,10 @@ module Adapters
undef :test_GET_with_body
end
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 unless defined? RUBY_ENGINE and 'jruby' == RUBY_ENGINE
end