From 24385e708ec111dc199c27d937c04656d6f8e6d9 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 29 Aug 2007 09:38:36 +0000 Subject: * lib/open-uri.rb: add :ftp_active_mode option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/open-uri.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/open-uri.rb') diff --git a/lib/open-uri.rb b/lib/open-uri.rb index a38d596562..a3b5879fdc 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -98,6 +98,7 @@ module OpenURI :read_timeout => true, :ssl_ca_cert => nil, :ssl_verify_mode => nil, + :ftp_active_mode => false, } def OpenURI.check_options(options) # :nodoc: @@ -607,6 +608,15 @@ module OpenURI # OpenURI::OpenRead#open returns an IO like object if block is not given. # Otherwise it yields the IO object and return the value of the block. # The IO object is extended with OpenURI::Meta. + # + # [:ftp_active_mode] + # Synopsis: + # :ftp_active_mode=>bool + # + # :ftp_active_mode=>true is used to make ftp active mode. + # Note that the active mode is default in Ruby 1.8 or prior. + # Ruby 1.9 uses passive mode by default. + # def open(*rest, &block) OpenURI.open_uri(self, *rest, &block) end @@ -743,7 +753,7 @@ module URI # The access sequence is defined by RFC 1738 ftp = Net::FTP.open(self.host) - ftp.passive = true + ftp.passive = true if !options[:ftp_active_mode] # todo: extract user/passwd from .netrc. user = 'anonymous' passwd = nil -- cgit v1.2.3