james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: james-server/src/java/org/apache/james/pop3server POP3Handler.java
Date Wed, 16 Jul 2003 04:03:23 GMT
noel        2003/07/15 21:03:23

  Modified:    src/java/org/apache/james/pop3server POP3Handler.java
  Log:
  Change to use CRLFTerminatedReader.  Follows same pattern that SMTPHandler has been using.
  
  Revision  Changes    Path
  1.31      +24 -4     james-server/src/java/org/apache/james/pop3server/POP3Handler.java
  
  Index: POP3Handler.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/pop3server/POP3Handler.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- POP3Handler.java	12 Jul 2003 23:44:25 -0000	1.30
  +++ POP3Handler.java	16 Jul 2003 04:03:22 -0000	1.31
  @@ -58,6 +58,7 @@
   
   package org.apache.james.pop3server;
   
  +import java.io.BufferedInputStream;
   import java.io.BufferedOutputStream;
   import java.io.BufferedReader;
   import java.io.IOException;
  @@ -81,6 +82,7 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.james.Constants;
   import org.apache.james.core.MailImpl;
  +import org.apache.james.util.CRLFTerminatedReader;
   import org.apache.james.util.ExtraDotOutputStream;
   import org.apache.james.util.InternetPrintWriter;
   import org.apache.james.util.watchdog.BytesWrittenResetOutputStream;
  @@ -265,7 +267,8 @@
               synchronized (this) {
                   handlerThread = Thread.currentThread();
               }
  -            in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ASCII"),
512);
  +            // in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ASCII"),
512);
  +            in = new CRLFTerminatedReader(new BufferedInputStream(socket.getInputStream(),
512), "ASCII");
               remoteIP = socket.getInetAddress().getHostAddress ();
               remoteHost = socket.getInetAddress().getHostName ();
           } catch (Exception e) {
  @@ -309,7 +312,7 @@
               out.println(responseBuffer.toString());
   
               theWatchdog.start();
  -            while (parseCommand(in.readLine())) {
  +            while (parseCommand(readCommandLine())) {
                   theWatchdog.reset();
               }
               theWatchdog.stop();
  @@ -444,6 +447,24 @@
       }
   
       /**
  +     * Reads a line of characters off the command line.
  +     *
  +     * @return the trimmed input line
  +     * @throws IOException if an exception is generated reading in the input characters
  +     */
  +    final String readCommandLine() throws IOException {
  +        for (;;) try {
  +            String commandLine = in.readLine();
  +            if (commandLine != null) {
  +                commandLine = commandLine.trim();
  +            }
  +            return commandLine;
  +        } catch (CRLFTerminatedReader.TerminationException te) {
  +            writeLoggedFlushedResponse("-ERR Syntax error at character position " + te.position()
+ ". CR and LF must be CRLF paired.  See RFC 1939 #3.");
  +        }
  +    }
  +
  +    /**
        * This method parses POP3 commands read off the wire in handleConnection.
        * Actual processing of the command (possibly including additional back and
        * forth communication with the client) is delegated to one of a number of
  @@ -460,8 +481,7 @@
               return false;
           }
           boolean returnValue = true;
  -        String command = rawCommand.trim();
  -        rawCommand = command;
  +        String command = rawCommand;
           StringTokenizer commandLine = new StringTokenizer(command, " ");
           int arguments = commandLine.countTokens();
           if (arguments == 0) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message