mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-10 00:03:09 -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_ssl req, env
|
||||||
configure_proxy req, env
|
configure_proxy req, env
|
||||||
configure_timeout req, env
|
configure_timeout req, env
|
||||||
|
configure_socket req, env
|
||||||
|
|
||||||
req.on_complete do |resp|
|
req.on_complete do |resp|
|
||||||
if resp.timed_out?
|
if resp.timed_out?
|
||||||
@ -88,6 +89,12 @@ module Faraday
|
|||||||
req.connect_timeout = (env_req[:open_timeout] * 1000) if env_req[:open_timeout]
|
req.connect_timeout = (env_req[:open_timeout] * 1000) if env_req[:open_timeout]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def configure_socket(req, env)
|
||||||
|
if bind = request_options(env)[:bind]
|
||||||
|
req.interface = bind[:host]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def request_options(env)
|
def request_options(env)
|
||||||
env[:request]
|
env[:request]
|
||||||
end
|
end
|
||||||
|
@ -10,5 +10,10 @@ module Adapters
|
|||||||
undef :test_GET_with_body
|
undef :test_GET_with_body
|
||||||
end
|
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 unless defined? RUBY_ENGINE and 'jruby' == RUBY_ENGINE
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user