mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-06 00:03:36 -04:00
set excon timeouts from faraday configuration and handle timeout errors
This commit is contained in:
parent
24ced570ed
commit
e27df4e915
@ -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
|
||||
|
@ -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']
|
||||
|
Loading…
x
Reference in New Issue
Block a user