diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-03 19:24:30 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-03 19:24:30 +0000 |
commit | bc2ece6cf8e9c96f94ba7335cef886b7c5c0f833 (patch) | |
tree | 022f60f9af8b0bf054d5b43798e0757ec7366103 /test | |
parent | d7655cc292c431264723547bbf8ea946517ca92c (diff) | |
download | ruby-bc2ece6cf8e9c96f94ba7335cef886b7c5c0f833.tar.gz |
* lib/ftp/ftp.rb (Net::FTP#close): close socket more gracefully.
* lib/ftp/ftp.rb (Net::BufferedSocket#shutdown): added.
* test/net/ftp/test_ftp.rb (FTPTest#create_ftp_server): wait socket
with shutdown and read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/net/ftp/test_ftp.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index c5f598fba6..cee4649493 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -375,14 +375,10 @@ class FTPTest < Test::Unit::TestCase commands.push(sock.gets) sock.print("150 Opening BINARY mode data connection for foo (#{binary_data.size} bytes)\r\n") conn = TCPSocket.new(host, port) - binary_data.scan(/.{1,1024}/nm).each_with_index do |s, i| - if i == 1 - sleep(0.5) - else - sleep(0.1) - end - conn.print(s) - end + sleep(0.1) + conn.print(binary_data[0,1024]) + sleep(0.5) + assert_raise(Errno::EPIPE){ conn.print(binary_data[1024, 1024]) } conn.close sock.print("226 Transfer complete.\r\n") } @@ -406,7 +402,7 @@ class FTPTest < Test::Unit::TestCase assert_equal("RETR foo\r\n", commands.shift) assert_equal(nil, commands.shift) ensure - ftp.close if ftp + ftp.close unless ftp.closed? end ensure server.close @@ -591,7 +587,9 @@ class FTPTest < Test::Unit::TestCase sock = server.accept begin yield(sock) - sleep 0.1 + sock.shutdown(Socket::SHUT_WR) + sock.read_timeout = 1 + sock.read unless sock.eof? ensure sock.close end |