From 9fd5174ef3aebe3d862289b4c646e65b2400b2f9 Mon Sep 17 00:00:00 2001 From: aamine Date: Mon, 27 Mar 2000 15:52:27 +0000 Subject: 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 --- lib/net/pop.rb | 86 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 38 deletions(-) (limited to 'lib/net/pop.rb') diff --git a/lib/net/pop.rb b/lib/net/pop.rb index 616f537f52..7a41e44350 100644 --- a/lib/net/pop.rb +++ b/lib/net/pop.rb @@ -71,8 +71,9 @@ Net::Protocol def do_start( acnt, pwd ) @command.auth( acnt, pwd ) - t = self.type.mail_type + @mails = [] + t = type.mail_type @command.list.each_with_index do |size,idx| if size then @mails.push t.new( idx, size, @command ) @@ -221,70 +222,81 @@ Net::POP3 def initialize( sock ) super - check_reply SuccessCode + critical { + check_reply SuccessCode + } end def auth( acnt, pass ) - @socket.writeline 'USER ' + acnt - check_reply_auth - - @socket.writeline( 'PASS ' + pass ) - ret = check_reply_auth + critical { + @socket.writeline 'USER ' + acnt + check_reply_auth - return ret + @socket.writeline 'PASS ' + pass + check_reply_auth + } end def list - getok 'LIST' - arr = [] - @socket.read_pendlist do |line| - num, siz = line.split( / +/o ) - arr[ num.to_i ] = siz.to_i - end - - return arr + critical { + getok 'LIST' + @socket.read_pendlist do |line| + num, siz = line.split( / +/o ) + arr[ num.to_i ] = siz.to_i + end + } + arr end def rset - getok 'RSET' + critical { + getok 'RSET' + } end def top( num, lines = 0, dest = '' ) - getok sprintf( 'TOP %d %d', num, lines ) - @socket.read_pendstr( dest ) + critical { + getok sprintf( 'TOP %d %d', num, lines ) + @socket.read_pendstr( dest ) + } end def retr( num, dest = '', &block ) - getok sprintf( 'RETR %d', num ) - @socket.read_pendstr( dest, &block ) + critical { + getok sprintf( 'RETR %d', num ) + @socket.read_pendstr( dest, &block ) + } end def dele( num ) - getok sprintf( 'DELE %d', num ) + critical { + getok sprintf( 'DELE %d', num ) + } end def uidl( num ) - rep = getok( sprintf 'UIDL %d', num ) - uid = rep.msg.split(' ')[1] - - uid + critical { + getok( sprintf 'UIDL %d', num ).msg.split(' ')[1] + } end - private + def quit + critical { + getok 'QUIT' + } + end - def do_quit - getok 'QUIT' - end + private def check_reply_auth @@ -326,19 +338,17 @@ Net::POP3 def auth( acnt, pass ) - @socket.writeline( "APOP #{acnt} #{digest(@stamp + pass)}" ) - return check_reply_auth + critical { + @socket.writeline( "APOP #{acnt} #{digest(@stamp + pass)}" ) + check_reply_auth + } end def digest( str ) - temp = MD5.new( str ).digest - ret = '' - temp.each_byte do |i| - ret << sprintf( '%02x', i ) - end - return ret + MD5.new( str ).digest.each_byte {|i| ret << sprintf('%02x', i) } + ret end end -- cgit v1.2.3