mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merged 16257 from trunk.
* lib/net/telnet.rb: This patch from Brian Candler adds a FailEOF mode which can be activated to have net/telnet raise EOFError exceptions when the remote connection is closed. The default behavior remains unchanged though. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
87e3939dcd
commit
889c22455a
2 changed files with 15 additions and 0 deletions
|
|
@ -1,3 +1,11 @@
|
||||||
|
Thu May 1 23:57:06 2008 James Edward Gray II <jeg2@ruby-lang.org>
|
||||||
|
|
||||||
|
Merged 16257 from trunk.
|
||||||
|
|
||||||
|
* lib/net/telnet.rb: This patch from Brian Candler adds a FailEOF mode which
|
||||||
|
can be activated to have net/telnet raise EOFError exceptions when the
|
||||||
|
remote connection is closed. The default behavior remains unchanged though.
|
||||||
|
|
||||||
Thu May 1 23:43:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu May 1 23:43:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* range.c (range_step): check if step can be converted to an integer.
|
* range.c (range_step): check if step can be converted to an integer.
|
||||||
|
|
|
||||||
|
|
@ -520,10 +520,15 @@ module Net
|
||||||
# value specified when this instance was created will be
|
# value specified when this instance was created will be
|
||||||
# used, or, failing that, the default value of 0 seconds,
|
# used, or, failing that, the default value of 0 seconds,
|
||||||
# which means not to wait for more input.
|
# which means not to wait for more input.
|
||||||
|
# FailEOF:: if true, when the remote end closes the connection then an
|
||||||
|
# EOFError will be raised. Otherwise, defaults to the old
|
||||||
|
# behaviour that the function will return whatever data
|
||||||
|
# has been received already, or nil if nothing was received.
|
||||||
#
|
#
|
||||||
def waitfor(options) # :yield: recvdata
|
def waitfor(options) # :yield: recvdata
|
||||||
time_out = @options["Timeout"]
|
time_out = @options["Timeout"]
|
||||||
waittime = @options["Waittime"]
|
waittime = @options["Waittime"]
|
||||||
|
fail_eof = @options["FailEOF"]
|
||||||
|
|
||||||
if options.kind_of?(Hash)
|
if options.kind_of?(Hash)
|
||||||
prompt = if options.has_key?("Match")
|
prompt = if options.has_key?("Match")
|
||||||
|
|
@ -535,6 +540,7 @@ module Net
|
||||||
end
|
end
|
||||||
time_out = options["Timeout"] if options.has_key?("Timeout")
|
time_out = options["Timeout"] if options.has_key?("Timeout")
|
||||||
waittime = options["Waittime"] if options.has_key?("Waittime")
|
waittime = options["Waittime"] if options.has_key?("Waittime")
|
||||||
|
fail_eof = options["FailEOF"] if options.has_key?("FailEOF")
|
||||||
else
|
else
|
||||||
prompt = options
|
prompt = options
|
||||||
end
|
end
|
||||||
|
|
@ -586,6 +592,7 @@ module Net
|
||||||
line += buf
|
line += buf
|
||||||
yield buf if block_given?
|
yield buf if block_given?
|
||||||
rescue EOFError # End of file reached
|
rescue EOFError # End of file reached
|
||||||
|
raise if fail_eof
|
||||||
if line == ''
|
if line == ''
|
||||||
line = nil
|
line = nil
|
||||||
yield nil if block_given?
|
yield nil if block_given?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue