mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-08 00:03:41 -04:00
Add bind option to Typhoeus [#154]
This commit is contained in:
parent
884ca38b4a
commit
d4d88a1de8
@ -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]
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user