set excon timeouts from faraday configuration and handle timeout errors

This commit is contained in:
Dan Dofter 2012-05-08 19:08:14 -07:00
parent 24ced570ed
commit e27df4e915
2 changed files with 16 additions and 3 deletions

View File

@ -11,6 +11,20 @@ module Faraday
opts[:ssl_verify_peer] = !!ssl.fetch(:verify, true)
opts[:ssl_ca_path] = ssl[:ca_file] if ssl[:ca_file]
end
if ( req = env[:request] )
if req[:timeout]
opts[:read_timeout] = req[:timeout]
opts[:connect_timeout] = req[:timeout]
opts[:write_timeout] = req[:timeout]
end
if req[:open_timeout]
opts[:connect_timeout] = req[:open_timeout]
opts[:write_timeout] = req[:open_timeout]
end
end
conn = ::Excon.new(env[:url].to_s, opts)
resp = conn.request \
@ -23,6 +37,8 @@ module Faraday
@app.call env
rescue ::Excon::Errors::SocketError
raise Error::ConnectionFailed, $!
rescue ::Excon::Errors::Timeout => err
raise Faraday::Error::TimeoutError, err
end
end
end

View File

@ -10,9 +10,6 @@ module Adapters
warn "Warning: Skipping Excon tests on Rubinius"
else
Integration.apply(self, :NonParallel) do
# https://github.com/eventmachine/eventmachine/pull/289
undef :test_timeout
# FIXME: this test fails on Travis with
# "Faraday::Error::ClientError: the server responded with status 400"
undef :test_POST_sends_files if ENV['CI']