summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 09:38:36 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-29 09:38:36 +0000
commit691fa20306244eb5864ea7f1e5520f57456f3cf4 (patch)
tree4639b60807381b48fe5ea1df71d686dd5da76809
parent8d2c4d5ba1be23917261d536ae78b35c53b18771 (diff)
downloadruby-691fa20306244eb5864ea7f1e5520f57456f3cf4.tar.gz
ruby-691fa20306244eb5864ea7f1e5520f57456f3cf4.tar.xz
ruby-691fa20306244eb5864ea7f1e5520f57456f3cf4.zip
* lib/open-uri.rb: add :ftp_active_mode option.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--lib/open-uri.rb12
2 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 3fd370de9..4f502b01b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Aug 29 18:36:06 2007 Tanaka Akira <akr@fsij.org>
+
+ * lib/open-uri.rb: add :ftp_active_mode option.
+
Wed Aug 29 12:48:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (aref_args): args may not be a list. [ruby-dev:31592]
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index a38d59656..a3b5879fd 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