[Spambayes-checkins] spambayes pop3proxy.py,1.43,1.44

Richie Hindle richiehindle at users.sourceforge.net
Sat Jan 25 04:56:00 EST 2003


Update of /cvsroot/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv7658

Modified Files:
	pop3proxy.py 
Log Message:
The POP3 proxy doesn't support pipelining, so it now filters out that
capability from the CAPA response.  This should fix François' strange
errors whereby the classification headers were appearing the middle
of message bodies, and messages were being split apart when they
were stored in the cache.


Index: pop3proxy.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/pop3proxy.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** pop3proxy.py	25 Jan 2003 10:16:16 -0000	1.43
--- pop3proxy.py	25 Jan 2003 12:55:58 -0000	1.44
***************
*** 261,265 ****
                              'STAT', 'DELE', 'NOOP', 'RSET', 'KILL']:
              return False
!         elif self.command in ['RETR', 'TOP']:
              return True
          elif self.command in ['LIST', 'UIDL']:
--- 261,265 ----
                              'STAT', 'DELE', 'NOOP', 'RSET', 'KILL']:
              return False
!         elif self.command in ['RETR', 'TOP', 'CAPA']:
              return True
          elif self.command in ['LIST', 'UIDL']:
***************
*** 316,319 ****
--- 316,325 ----
  
      def onResponse(self):
+         # We don't support pipelining, so if the command is CAPA and the
+         # response includes PIPELINING, hack out that line of the response.
+         if self.command == 'CAPA':
+             pipelineRE = r'(?im)^PIPELINING[^\n]*\n'
+             self.response = re.sub(pipelineRE, '', self.response)
+ 
          # Pass the request and the raw response to the subclass and
          # send back the cooked response.
***************
*** 1296,1300 ****
          self.okCommands = ['USER', 'PASS', 'APOP', 'NOOP',
                             'DELE', 'RSET', 'QUIT', 'KILL']
!         self.handlers = {'STAT': self.onStat,
                           'LIST': self.onList,
                           'RETR': self.onRetr,
--- 1302,1307 ----
          self.okCommands = ['USER', 'PASS', 'APOP', 'NOOP',
                             'DELE', 'RSET', 'QUIT', 'KILL']
!         self.handlers = {'CAPA': self.onCapa,
!                          'STAT': self.onStat,
                           'LIST': self.onList,
                           'RETR': self.onRetr,
***************
*** 1333,1336 ****
--- 1340,1355 ----
              time.sleep(0.02)
  
+     def onCapa(self, command, args):
+         """POP3 CAPA command.  This lies about supporting pipelining for
+         test purposes - the POP3 proxy *doesn't* support pipelining, and
+         we test that it correctly filters out that capability from the
+         proxied capability list."""
+         lines = ["+OK Capability list follows",
+                  "PIPELINING",
+                  "TOP",
+                  ".",
+                  ""]
+         return '\r\n'.join(lines)
+ 
      def onStat(self, command, args):
          """POP3 STAT command."""
***************
*** 1421,1429 ****
      proxyReady.wait()
  
!     # Connect to the proxy.
      proxy = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      proxy.connect(('localhost', 8111))
      response = proxy.recv(100)
      assert response == "+OK ready\r\n"
  
      # Stat the mailbox to get the number of messages.
--- 1440,1463 ----
      proxyReady.wait()
  
!     # Connect to the proxy and the test server.
      proxy = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      proxy.connect(('localhost', 8111))
      response = proxy.recv(100)
      assert response == "+OK ready\r\n"
+     pop3Server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+     pop3Server.connect(('localhost', 8110))
+     response = pop3Server.recv(100)
+     assert response == "+OK ready\r\n"
+ 
+     # Verify that the test server claims to support pipelining.
+     pop3Server.send("capa\r\n")
+     response = pop3Server.recv(1000)
+     assert response.find("PIPELINING") >= 0
+ 
+     # Ask for the capabilities via the proxy, and verify that the proxy
+     # is filtering out the PIPELINING capability.
+     proxy.send("capa\r\n")
+     response = proxy.recv(1000)
+     assert response.find("PIPELINING") == -1
  
      # Stat the mailbox to get the number of messages.
***************
*** 1456,1461 ****
      proxy.sendall("kill\r\n")
      proxy.recv(100)
-     pop3Server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-     pop3Server.connect(('localhost', 8110))
      pop3Server.sendall("kill\r\n")
      pop3Server.recv(100)
--- 1490,1493 ----





More information about the Spambayes-checkins mailing list