summaryrefslogtreecommitdiff
path: root/lib/net/protocol.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-27 15:52:27 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-27 15:52:27 +0000
commit9fd5174ef3aebe3d862289b4c646e65b2400b2f9 (patch)
tree36ba0828cb3b1f2bb70a53e7661a6e9ca7162f78 /lib/net/protocol.rb
parent0dcf7498b10c7fd4739b34236502efd8e0f8353c (diff)
v1.1.11
o all: use "critical" to avoid duplicated command dispatch o http.rb: change get2, post2 usage (HTTPWriter) o http.rb: entity reading algorithm is better o http.rb: more reply code (4xx, 5xx) o protocol.rb: arguments of "connect" can be omitted o protocol.rb: "quit" is not template method (now do_quit is removed) o protocol.rb: ReplyCode.error_type was not work: using module_eval git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/protocol.rb')
-rw-r--r--lib/net/protocol.rb58
1 files changed, 37 insertions, 21 deletions
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 4f2bf17..776dba7 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -15,7 +15,7 @@ require 'socket'
module Net
- Version = '1.1.10'
+ Version = '1.1.11'
=begin
@@ -144,7 +144,7 @@ Object
def initialize( addr = nil, port = nil )
@address = addr || 'localhost'
- @port = port || self.type.port
+ @port = port || type.port
@active = false
@pipe = nil
@@ -160,11 +160,11 @@ Object
def start( *args )
return false if active?
- @active = true
begin
- connect @address, @port
+ connect
do_start *args
+ @active = true
yield if iterator?
ensure
finish if iterator?
@@ -174,7 +174,7 @@ Object
def finish
ret = active?
- do_finish if @command
+ do_finish
disconnect
@active = false
@@ -201,9 +201,9 @@ Object
end
- def connect( addr, port )
- @socket = self.type.socket_type.open( addr, port, @pipe )
- @command = self.type.command_type.new( @socket )
+ def connect( addr = @address, port = @port )
+ @socket = type.socket_type.open( addr, port, @pipe )
+ @command = type.command_type.new( @socket )
end
def disconnect
@@ -213,7 +213,7 @@ Object
end
@socket = nil
end
-
+
end
Session = Protocol
@@ -226,24 +226,17 @@ Object
@socket = sock
@error_occured = false
@last_reply = nil
+ @critical = false
end
attr_reader :socket, :error_occured, :last_reply
attr_writer :socket
- def quit
- if @socket and not @socket.closed? then
- do_quit
- @error_occured = false
- end
- end
+ # abstract quit
private
- def do_quit
- end
-
# abstract get_reply()
def check_reply( *oks )
@@ -266,7 +259,30 @@ Object
@socket.writeline line
check_reply ok
end
-
+
+
+ def critical
+ return if @critical
+ @critical = true
+ r = yield
+ @critical = false
+ r
+ end
+
+ def critical?
+ @critical
+ end
+
+ def begin_critical
+ ret = @critical
+ @critical = true
+ not ret
+ end
+
+ def end_critical
+ @critical = false
+ end
+
end
@@ -284,11 +300,11 @@ Object
class << self
def error_type( err )
- @err = err
+ module_eval "def self.get_error_type() #{err.name} end"
end
def error!( mes )
- raise @err, mes
+ raise get_error_type, mes
end
end