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?
@ -87,6 +88,12 @@ module Faraday
req.timeout = req.connect_timeout = (env_req[:timeout] * 1000) if env_req[:timeout]
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]

View File

@ -9,6 +9,11 @@ module Adapters
# https://github.com/dbalatero/typhoeus/issues/75
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