1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add a new optinal argument pathname to FTP#stat.

Based on the patch by soleboxy.
[Fix GH-1478] [ruby-core:78240] [Feature #12965]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2016-11-23 00:03:27 +00:00
parent 5660bb929f
commit e50266f299
3 changed files with 40 additions and 4 deletions

1
NEWS
View file

@ -205,6 +205,7 @@ with all sufficient information, see the ChangeLog file or Redmine
* Support TLS (RFC 4217).
* Support hash style options for Net::FTP.new.
* Add a new optional argument pathname to Net::FTP#status.
* OpenSSL

View file

@ -1226,11 +1226,13 @@ module Net
#
# Returns the status (STAT command).
# pathname - when stat is invoked with pathname as a parameter it acts like
# list but alot faster and over the same tcp session.
#
def status
line = "STAT" + CRLF
print "put: STAT\n" if @debug_mode
@sock.send(line, Socket::MSG_OOB)
def status(pathname = nil)
line = pathname ? "STAT #{pathname}" : "STAT"
print "put: #{line}\n" if @debug_mode
@sock.send(line + CRLF, Socket::MSG_OOB)
return getresp
end

View file

@ -1316,6 +1316,39 @@ EOF
end
end
def test_status_path
commands = []
server = create_ftp_server { |sock|
sock.print("220 (test_ftp).\r\n")
commands.push(sock.gets)
sock.print("331 Please specify the password.\r\n")
commands.push(sock.gets)
sock.print("230 Login successful.\r\n")
commands.push(sock.gets)
sock.print("200 Switching to Binary mode.\r\n")
commands.push(sock.gets)
sock.print("213 End of status\r\n")
}
begin
begin
ftp = Net::FTP.new
ftp.read_timeout = 0.2
ftp.connect(SERVER_ADDR, server.port)
ftp.login
assert_match(/\AUSER /, commands.shift)
assert_match(/\APASS /, commands.shift)
assert_equal("TYPE I\r\n", commands.shift)
ftp.status "/"
assert_equal("STAT /\r\n", commands.shift)
assert_equal(nil, commands.shift)
ensure
ftp.close if ftp
end
ensure
server.close
end
end
def test_pathnames
require 'pathname'