diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-11 03:48:45 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-11 03:48:45 +0000 |
commit | 58af10ecbdfa4053eeafa9c8bcdcda54be7125d7 (patch) | |
tree | 9e024cdf39ee192e781d58821692c82151ead7a2 /lib | |
parent | f8cd2190f031a3588e1057d08d3ae8d3c864eb18 (diff) | |
download | ruby-58af10ecbdfa4053eeafa9c8bcdcda54be7125d7.tar.gz |
* 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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net/ftp.rb | 17 | ||||
-rw-r--r-- | lib/open-uri.rb | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 879206c7dd..26bca1a54a 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -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 diff --git a/lib/open-uri.rb b/lib/open-uri.rb index c63e5292aa..9e4a5e24c1 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -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 |