mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/ftp.rb (initialize): Connections are in passive mode per
default now. The default mode can be changed by Net::FTP.default_passive=. * lib/net/ftp.rb (default_passive=, default_passive): new methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f8cd2190f0
commit
58af10ecbd
5 changed files with 31 additions and 3 deletions
|
@ -1,3 +1,11 @@
|
|||
Wed Nov 11 11:58:38 2015 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* lib/net/ftp.rb (initialize): Connections are in passive mode per
|
||||
default now. The default mode can be changed by
|
||||
Net::FTP.default_passive=.
|
||||
|
||||
* lib/net/ftp.rb (default_passive=, default_passive): new methods.
|
||||
|
||||
Wed Nov 11 09:03:12 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* sprintf.c (rb_str_format): respect default value of a hash. no
|
||||
|
|
4
NEWS
4
NEWS
|
@ -196,6 +196,10 @@ with all sufficient information, see the ChangeLog file.
|
|||
* Net::Telnet
|
||||
* Net::Telnet is extracted to net-telnet gem. It's unmaintain code.
|
||||
|
||||
* Net::FTP
|
||||
* Connections are in passive mode per default now. The default mode can
|
||||
be changed by Net::FTP.default_passive=.
|
||||
|
||||
* Rake
|
||||
* Rake is removed from stdlib.
|
||||
|
||||
|
|
|
@ -80,12 +80,13 @@ module Net
|
|||
FTP_PORT = 21
|
||||
CRLF = "\r\n"
|
||||
DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE
|
||||
@@default_passive = true
|
||||
# :startdoc:
|
||||
|
||||
# When +true+, transfers are performed in binary mode. Default: +true+.
|
||||
attr_reader :binary
|
||||
|
||||
# When +true+, the connection is in passive mode. Default: +false+.
|
||||
# When +true+, the connection is in passive mode. Default: +true+.
|
||||
attr_accessor :passive
|
||||
|
||||
# When +true+, all traffic to and from the server is written
|
||||
|
@ -124,6 +125,18 @@ module Net
|
|||
# The server's last response.
|
||||
attr_reader :last_response
|
||||
|
||||
# When +true+, connections are in passive mode per default.
|
||||
# Default: +true+.
|
||||
def self.default_passive=(value)
|
||||
@@default_passive = value
|
||||
end
|
||||
|
||||
# When +true+, connections are in passive mode per default.
|
||||
# Default: +true+.
|
||||
def self.default_passive
|
||||
@@default_passive
|
||||
end
|
||||
|
||||
#
|
||||
# A synonym for <tt>FTP.new</tt>, but with a mandatory host parameter.
|
||||
#
|
||||
|
@ -151,7 +164,7 @@ module Net
|
|||
def initialize(host = nil, user = nil, passwd = nil, acct = nil)
|
||||
super()
|
||||
@binary = true
|
||||
@passive = false
|
||||
@passive = @@default_passive
|
||||
@debug_mode = false
|
||||
@resume = false
|
||||
@sock = NullSocket.new
|
||||
|
|
|
@ -773,7 +773,7 @@ module URI
|
|||
# The access sequence is defined by RFC 1738
|
||||
ftp = Net::FTP.new
|
||||
ftp.connect(self.hostname, self.port)
|
||||
ftp.passive = true if !options[:ftp_active_mode]
|
||||
ftp.passive = !options[:ftp_active_mode]
|
||||
# todo: extract user/passwd from .netrc.
|
||||
user = 'anonymous'
|
||||
passwd = nil
|
||||
|
|
|
@ -11,9 +11,12 @@ class FTPTest < Test::Unit::TestCase
|
|||
|
||||
def setup
|
||||
@thread = nil
|
||||
@default_passive = Net::FTP.default_passive
|
||||
Net::FTP.default_passive = false
|
||||
end
|
||||
|
||||
def teardown
|
||||
Net::FTP.default_passive = @default_passive
|
||||
if @thread
|
||||
@thread.join
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue