incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r535977 - in /incubator/ftpserver/trunk/core/src: java/org/apache/ftpserver/IODataConnection.java test/org/apache/ftpserver/clienttests/RetrieveTest.java test/org/apache/ftpserver/clienttests/StoreTest.java
Date Mon, 07 May 2007 20:17:31 GMT
Author: ngn
Date: Mon May  7 13:17:29 2007
New Revision: 535977

URL: http://svn.apache.org/viewvc?view=rev&rev=535977
Log:
Fixed bug where we would send duplicated CRs (FTPSERVER-84).

Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnection.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
    incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnection.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnection.java?view=diff&rev=535977&r1=535976&r2=535977
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnection.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/IODataConnection.java Mon
May  7 13:17:29 2007
@@ -174,7 +174,7 @@
     
             bos = IoUtils.getBufferedOutputStream( out );
             
-            
+            boolean lastWasCR = false;
             while(true) {
                 
                 // if current rate exceeds the max rate, sleep for 50ms 
@@ -207,8 +207,14 @@
                 if(isAscii) {
                     for(int i=0; i<count; ++i) {
                         byte b = buff[i];
-                        if(b == '\n') {
+                        if(b == '\n' && !lastWasCR) {
                             bos.write('\r');
+                        } 
+                        
+                        if(b == '\r') {
+                            lastWasCR = true;
+                        } else {
+                            lastWasCR = false;
                         }
                         bos.write(b);
                     }

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java?view=diff&rev=535977&r1=535976&r2=535977
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/RetrieveTest.java
Mon May  7 13:17:29 2007
@@ -37,7 +37,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        testData = "TESTDATA".getBytes("UTF-8");
+        testData = "TESTDATA\r\n".getBytes("UTF-8");
         
         client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
     }

Modified: incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java?view=diff&rev=535977&r1=535976&r2=535977
==============================================================================
--- incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
(original)
+++ incubator/ftpserver/trunk/core/src/test/org/apache/ftpserver/clienttests/StoreTest.java
Mon May  7 13:17:29 2007
@@ -21,13 +21,15 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
+import java.io.FileInputStream;
 
 import org.apache.commons.net.ftp.FTPClient;
 import org.apache.ftpserver.test.TestUtil;
+import org.apache.ftpserver.util.IoUtils;
 
 
 public class StoreTest extends ClientTestTemplate {
-    private static final String TESTDATA = "TESTDATA";
+    private static final String TESTDATA = "TESTDATA\r\nline2\r\n";
 
     private static final String ENCODING = "UTF-8";
 



Mime
View raw message