Feature #6088 » net.modernize_timeout_usage.open_timeout.patch
lib/net/pop.rb (working copy) | ||
---|---|---|
# internal method for Net::POP3.start
|
||
def do_start(account, password) # :nodoc:
|
||
s = timeout(@open_timeout) { TCPSocket.open(@address, port) }
|
||
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
|
||
TCPSocket.open(@address, port)
|
||
end
|
||
if use_ssl?
|
||
raise 'openssl library not installed' unless defined?(OpenSSL)
|
||
context = OpenSSL::SSL::SSLContext.new
|
lib/net/http.rb (working copy) | ||
---|---|---|
def connect
|
||
D "opening connection to #{conn_address()}..."
|
||
s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }
|
||
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
|
||
TCPSocket.open(conn_address(), conn_port())
|
||
end
|
||
D "opened"
|
||
if use_ssl?
|
||
ssl_parameters = Hash.new
|
||
... | ... | |
end
|
||
# Server Name Indication (SNI) RFC 3546
|
||
s.hostname = @address if s.respond_to? :hostname=
|
||
timeout(@open_timeout) { s.connect }
|
||
Timeout.timeout(@open_timeout, Net::OpenTimeout) { s.connect }
|
||
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
||
s.post_connection_check(@address)
|
||
end
|
lib/net/protocol.rb (working copy) | ||
---|---|---|
class ProtoCommandError < ProtocolError; end
|
||
class ProtoRetriableError < ProtocolError; end
|
||
ProtocRetryError = ProtoRetriableError
|
||
class OpenTimeout < Timeout::Error; end
|
||
class BufferedIO #:nodoc: internal use only
|
lib/net/smtp.rb (working copy) | ||
---|---|---|
check_auth_method(authtype || DEFAULT_AUTH_TYPE)
|
||
check_auth_args user, secret
|
||
end
|
||
s = timeout(@open_timeout) { tcp_socket(@address, @port) }
|
||
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
|
||
tcp_socket(@address, @port)
|
||
end
|
||
logging "Connection opened: #{@address}:#{@port}"
|
||
@socket = new_internet_message_io(tls? ? tlsconnect(s) : s)
|
||
check_response critical { recv_response() }
|
lib/net/telnet.rb (working copy) | ||
---|---|---|
if @options["Timeout"] == false
|
||
@sock = TCPSocket.open(@options["Host"], @options["Port"])
|
||
else
|
||
timeout(@options["Timeout"]) do
|
||
Timeout.timeout(@options["Timeout"], Net::OpenTimeout) do
|
||
@sock = TCPSocket.open(@options["Host"], @options["Port"])
|
||
end
|
||
end
|
||
rescue TimeoutError
|
||
raise TimeoutError, "timed out while opening a connection to the host"
|
||
rescue Net::OpenTimeout
|
||
raise Net::OpenTimeout, "timed out while opening a connection to the host"
|
||
rescue
|
||
@log.write($ERROR_INFO.to_s + "\n") if @options.has_key?("Output_log")
|
||
@dumplog.log_dump('#', $ERROR_INFO.to_s + "\n") if @options.has_key?("Dump_log")
|
||
... | ... | |
# into a regular expression. Used only if Match and
|
||
# Prompt are not specified.
|
||
# Timeout:: the number of seconds to wait for data from the host
|
||
# before raising a TimeoutError. If set to false,
|
||
# before raising a Timeout::Error. If set to false,
|
||
# no timeout will occur. If not specified, the
|
||
# Timeout option value specified when this instance
|
||
# was created will be used, or, failing that, the
|
test/net/http/test_https.rb (working copy) | ||
---|---|---|
conn.open_timeout = 1
|
||
th = Thread.new do
|
||
assert_raise(Timeout::Error) {
|
||
assert_raise(Net::OpenTimeout) {
|
||
conn.get('/')
|
||
}
|
||
end
|