james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r930727 - in /james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core: RetrCmdHandler.java TopCmdHandler.java
Date Sun, 04 Apr 2010 18:01:50 GMT
Author: norman
Date: Sun Apr  4 18:01:50 2010
New Revision: 930727

URL: http://svn.apache.org/viewvc?rev=930727&view=rev
Log:
Make sure we write an extra dot if a line starts with a dot

Modified:
    james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/RetrCmdHandler.java
    james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/TopCmdHandler.java

Modified: james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/RetrCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/RetrCmdHandler.java?rev=930727&r1=930726&r2=930727&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/RetrCmdHandler.java
(original)
+++ james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/RetrCmdHandler.java
Sun Apr  4 18:01:50 2010
@@ -40,6 +40,7 @@ import org.apache.james.protocols.api.Co
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.socket.MessageStream;
+import org.apache.james.util.stream.ExtraDotOutputStream;
 
 /**
  * Handles RETR command
@@ -74,14 +75,21 @@ public class RetrCmdHandler implements C
                     Iterator<MessageResult> results = session.getUserMailbox().getMessages(MessageRange.one(uid),
new FetchGroupImpl(FetchGroup.FULL_CONTENT), mailboxSession);
                     MessageStream stream = new MessageStream();
                     OutputStream out = stream.getOutputStream();
+                    OutputStream extraDotOut = new ExtraDotOutputStream(out);
+                    
                     out.write((POP3Response.OK_RESPONSE + " Message follows\r\n").getBytes());
+                    out.flush();
+                    
                     // response = new POP3Response(POP3Response.OK_RESPONSE,
                     // "Message follows");
                     try {
                         MessageResult result = results.next();
-                        result.getFullContent().writeTo(Channels.newChannel(out));
+                        result.getFullContent().writeTo(Channels.newChannel(extraDotOut));
 
-                    } finally {
+                    } finally { 
+                        extraDotOut.flush();
+                        
+                        // write a single dot to mark message as complete
                         out.write((".\r\n").getBytes());
                         out.flush();
                     }

Modified: james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/TopCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/TopCmdHandler.java?rev=930727&r1=930726&r2=930727&view=diff
==============================================================================
--- james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/TopCmdHandler.java
(original)
+++ james/server/trunk/pop3server/src/main/java/org/apache/james/pop3server/core/TopCmdHandler.java
Sun Apr  4 18:01:50 2010
@@ -42,6 +42,7 @@ import org.apache.james.pop3server.POP3S
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.socket.MessageStream;
+import org.apache.james.util.stream.ExtraDotOutputStream;
 
 /**
  * Handles TOP command
@@ -97,13 +98,16 @@ public class TopCmdHandler extends RetrC
                     Iterator<MessageResult> results = session.getUserMailbox().getMessages(MessageRange.one(uid),
fetchGroup, mailboxSession);
                     MessageStream stream = new MessageStream();
                     OutputStream out = stream.getOutputStream();
+                    OutputStream extraDotOut = new ExtraDotOutputStream(out);
+                    
                     out.write((POP3Response.OK_RESPONSE + " Message follows\r\n").getBytes());
+                    out.flush();
                     // response = new POP3Response(POP3Response.OK_RESPONSE,
                     // "Message follows");
                     try {
                         MessageResult result = results.next();
 
-                        WritableByteChannel outChannel = Channels.newChannel(out);
+                        WritableByteChannel outChannel = Channels.newChannel(extraDotOut);
 
                         // write headers
                         Iterator<Header> headers = result.headers();
@@ -111,16 +115,18 @@ public class TopCmdHandler extends RetrC
                             headers.next().writeTo(outChannel);
 
                             // we need to write out the CRLF after each header
-                            out.write("\r\n".getBytes());
+                            extraDotOut.write("\r\n".getBytes());
 
                         }
                         // headers and body are seperated by a CRLF
-                        out.write("\r\n".getBytes());
+                        extraDotOut.write("\r\n".getBytes());
 
                         // write body
-                        result.getBody().writeTo(Channels.newChannel(new CountingBodyOutputStream(out,
lines)));
+                        result.getBody().writeTo(Channels.newChannel(new CountingBodyOutputStream(extraDotOut,
lines)));
 
                     } finally {
+                        extraDotOut.flush();
+                        // write a single dot to mark message as complete
                         out.write((".\r\n").getBytes());
                         out.flush();
                     }



---------------------------------------------------------------------
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