mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
Drop ruby 1.9 compat for open/read timeouts.
This commit is contained in:
parent
f0e2dc4327
commit
30ef4d39ca
1 changed files with 7 additions and 12 deletions
|
@ -557,7 +557,8 @@ module RestClient
|
|||
def transmit uri, req, payload, & block
|
||||
|
||||
# We set this to true in the net/http block so that we can distinguish
|
||||
# read_timeout from open_timeout. This isn't needed in Ruby >= 2.0.
|
||||
# read_timeout from open_timeout. Now that we only support Ruby 2.0+,
|
||||
# this is only needed for Timeout exceptions thrown outside of Net::HTTP.
|
||||
established_connection = false
|
||||
|
||||
setup_credentials req
|
||||
|
@ -641,18 +642,12 @@ module RestClient
|
|||
end
|
||||
rescue EOFError
|
||||
raise RestClient::ServerBrokeConnection
|
||||
rescue Net::OpenTimeout => err
|
||||
raise RestClient::Exceptions::OpenTimeout.new(nil, err)
|
||||
rescue Net::ReadTimeout => err
|
||||
raise RestClient::Exceptions::ReadTimeout.new(nil, err)
|
||||
rescue Timeout::Error, Errno::ETIMEDOUT => err
|
||||
# Net::HTTP has OpenTimeout, ReadTimeout in Ruby >= 2.0
|
||||
if defined?(Net::OpenTimeout)
|
||||
case err
|
||||
when Net::OpenTimeout
|
||||
raise RestClient::Exceptions::OpenTimeout.new(nil, err)
|
||||
when Net::ReadTimeout
|
||||
raise RestClient::Exceptions::ReadTimeout.new(nil, err)
|
||||
end
|
||||
end
|
||||
|
||||
# compatibility for Ruby 1.9.3, handling for non-Net::HTTP timeouts
|
||||
# handling for non-Net::HTTP timeouts
|
||||
if established_connection
|
||||
raise RestClient::Exceptions::ReadTimeout.new(nil, err)
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue