summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-29 14:39:54 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-29 14:39:54 +0000
commite7a8de3d316fb186aad2fea14c01497ce3d04789 (patch)
treede99c6531bdbb6cbeaf919eb93c4b6fda9ee2fae /lib
parenta6059573355b13a6b83c3293f5052507a14ea6a2 (diff)
downloadruby-e7a8de3d316fb186aad2fea14c01497ce3d04789.tar.gz
ruby-e7a8de3d316fb186aad2fea14c01497ce3d04789.tar.xz
ruby-e7a8de3d316fb186aad2fea14c01497ce3d04789.zip
* lib/net/http.rb (finish): does not raise IOError even if !started?, to allow duplicated #finish call.
* lib/net/pop.rb (finish): ditto. * lib/net/smtp.rb (finish): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/http.rb4
-rw-r--r--lib/net/pop.rb6
-rw-r--r--lib/net/smtp.rb7
3 files changed, 5 insertions, 12 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 38dca6a44..bb4934be6 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -416,7 +416,7 @@ module Net # :nodoc:
do_start
return yield(self)
ensure
- finish if @started
+ finish
end
end
do_start
@@ -437,9 +437,7 @@ module Net # :nodoc:
private :on_connect
# Finishes HTTP session and closes TCP connection.
- # If HTTP session had not started, raises an IOError.
def finish
- raise IOError, 'closing already closed HTTP session' unless @started
@socket.close if @socket and not @socket.closed?
@socket = nil
@started = false
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 2d4b57162..00a7af2bd 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -415,7 +415,7 @@ module Net
do_start account, password
return yield(self)
ensure
- finish if @started
+ finish
end
else
do_start account, password
@@ -441,10 +441,8 @@ module Net
end
private :on_connect
- # Finishes a POP3 session.
- # If a POP3 session has not been started, raises an IOError.
+ # Finishes a POP3 session and closes TCP connection.
def finish
- raise IOError, 'already closed POP session' unless @started
@mails = nil
@command.quit if @command
@command = nil
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index d2de78239..b14d43832 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -331,7 +331,7 @@ module Net # :nodoc:
do_start(helo, user, secret, authtype)
return yield(self)
ensure
- finish if @started
+ finish
end
else
do_start(helo, user, secret, authtype)
@@ -365,11 +365,8 @@ module Net # :nodoc:
end
private :do_start
- # Finish (close) the SMTP session.
- #
- # If the SMTP session has not been started, an IOError is raised.
+ # Finishes the SMTP session and closes TCP connection.
def finish
- raise IOError, 'closing already closed SMTP session' unless @started
quit if @socket and not @socket.closed? and not @error_occured
@socket.close if @socket and not @socket.closed?
@socket = nil