You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jakarta.apache.org by se...@apache.org on 2010/12/02 16:22:38 UTC

svn commit: r1041406 - in /jakarta/jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java xdocs/changes.xml

Author: sebb
Date: Thu Dec  2 15:22:37 2010
New Revision: 1041406

URL: http://svn.apache.org/viewvc?rev=1041406&view=rev
Log:
Bug 50392 - value is trimmed when sending the request in Multipart

Modified:
    jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java
    jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java
    jakarta/jmeter/trunk/xdocs/changes.xml

Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java?rev=1041406&r1=1041405&r2=1041406&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java Thu Dec  2 15:22:37 2010
@@ -143,14 +143,19 @@ public class MultipartUrlConfig implemen
                 }
                 else {
                     // Find the first empty line of the multipart, it signals end of headers for multipart
-                    int indexEmptyLfCrLfLinePos = parts[i].indexOf("\n\r\n"); //$NON-NLS-1$
-                    int indexEmptyLfLfLinePos = parts[i].indexOf("\n\n"); //$NON-NLS-1$
+                    // Agents are supposed to terminate lines in CRLF:
+                    final String CRLF = "\r\n";
+                    final String CRLFCRLF = "\r\n\r\n";
+                    // Code also allows for LF only (not sure why - perhaps because the test code uses it?)
+                    final String LF = "\n";
+                    final String LFLF = "\n\n";
+                    int indexEmptyCrLfCrLfLinePos = parts[i].indexOf(CRLFCRLF); //$NON-NLS-1$
+                    int indexEmptyLfLfLinePos = parts[i].indexOf(LFLF); //$NON-NLS-1$
                     String value = null;
-                    if(indexEmptyLfCrLfLinePos > -1) {
-                        value = parts[i].substring(indexEmptyLfCrLfLinePos).trim();
-                    }
-                    else if(indexEmptyLfLfLinePos > -1) {
-                        value = parts[i].substring(indexEmptyLfLfLinePos).trim();
+                    if(indexEmptyCrLfCrLfLinePos > -1) {// CRLF blank line found
+                        value = parts[i].substring(indexEmptyCrLfCrLfLinePos+CRLFCRLF.length(),parts[i].lastIndexOf(CRLF));
+                    } else if(indexEmptyLfLfLinePos > -1) { // LF blank line found
+                        value = parts[i].substring(indexEmptyLfLfLinePos+LFLF.length(),parts[i].lastIndexOf(LF));
                     }
                     this.addNonEncodedArgument(name, value);
                 }

Modified: jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java?rev=1041406&r1=1041405&r2=1041406&view=diff
==============================================================================
--- jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java (original)
+++ jakarta/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/config/MultipartUrlConfigTest.java Thu Dec  2 15:22:37 2010
@@ -42,19 +42,27 @@ public class MultipartUrlConfigTest exte
         assertEquals("boundary", muc.getBoundary());
     }
 
-    public void testParseArguments() {
+    // TODO - should LF-only EOL be allowed? 
+    public void testParseArgumentsLF() {
         String queryString
             = "Content-Disposition: form-data; name=\"aa\"\n"
             + "Content-Type: text/plain; charset=ISO-8859-1\n"
             + "Content-Transfer-Encoding: 8bit\n"
             + "\n"
-            + "aa\n"
+            + "bb\n"
             + "--7d159c1302d0y0\n"
             + "Content-Disposition: form-data; name=\"xx\"\n"
             + "Content-Type: text/plain; charset=ISO-8859-1\n"
             + "Content-Transfer-Encoding: 8bit\n"
             + "\n"
-            + "xx\n"
+            + "yy\n"
+            + "--7d159c1302d0y0\n"
+            + "Content-Disposition: form-data; name=\"abc\"\n"
+            + "Content-Type: text/plain; charset=ISO-8859-1\n"
+            + "Content-Transfer-Encoding: 8bit\n"
+            + "\n"
+            + "xyz  \n"
+            + "xyz  \n"
             + "--7d159c1302d0y0\n"
             + "Content-Disposition: form-data; name=\"param1\"; filename=\"file1\"\n"
             + "Content-Type: text/plain\n"
@@ -71,12 +79,63 @@ public class MultipartUrlConfigTest exte
         assertEquals("param1", file.getParamName());
         assertEquals("text/plain", file.getMimeType());
         Arguments args = muc.getArguments();
-        assertEquals(2, args.getArgumentCount());
+        assertEquals(3, args.getArgumentCount());
+        Argument arg = args.getArgument(0);
+        assertEquals("aa", arg.getName());
+        assertEquals("bb", arg.getValue());
+        arg = args.getArgument(1);
+        assertEquals("xx", arg.getName());
+        assertEquals("yy", arg.getValue());
+        arg = args.getArgument(2);
+        assertEquals("abc", arg.getName());
+        assertEquals("xyz  \nxyz  ", arg.getValue());
+    }
+
+    public void testParseArgumentsCRLF() {
+        String queryString
+            = "Content-Disposition: form-data; name=\"aa\"\r\n"
+            + "Content-Type: text/plain; charset=ISO-8859-1\r\n"
+            + "Content-Transfer-Encoding: 8bit\r\n"
+            + "\r\n"
+            + "bb\r\n"
+            + "--7d159c1302d0y0\r\n"
+            + "Content-Disposition: form-data; name=\"xx\"\r\n"
+            + "Content-Type: text/plain; charset=ISO-8859-1\r\n"
+            + "Content-Transfer-Encoding: 8bit\r\n"
+            + "\r\n"
+            + "yy\r\n"
+            + "--7d159c1302d0y0\r\n"
+            + "Content-Disposition: form-data; name=\"abc\"\r\n"
+            + "Content-Type: text/plain; charset=ISO-8859-1\r\n"
+            + "Content-Transfer-Encoding: 8bit\r\n"
+            + "\r\n"
+            + "xyz  \r\n"
+            + "xyz  \r\n"
+            + "--7d159c1302d0y0\r\n"
+            + "Content-Disposition: form-data; name=\"param1\"; filename=\"file1\"\r\n"
+            + "Content-Type: text/plain\r\n"
+            + "Content-Transfer-Encoding: binary\r\n"
+            + "\r\n"
+            + "file content\r\n"
+            + "\r\n";
+        MultipartUrlConfig muc = new MultipartUrlConfig("7d159c1302d0y0");
+        muc.parseArguments(queryString);
+        HTTPFileArgs files = muc.getHTTPFileArgs();
+        assertEquals(1, files.getHTTPFileArgCount());
+        HTTPFileArg file = (HTTPFileArg) files.iterator().next().getObjectValue();
+        assertEquals("file1", file.getPath());
+        assertEquals("param1", file.getParamName());
+        assertEquals("text/plain", file.getMimeType());
+        Arguments args = muc.getArguments();
+        assertEquals(3, args.getArgumentCount());
         Argument arg = args.getArgument(0);
         assertEquals("aa", arg.getName());
-        assertEquals("aa", arg.getValue());
+        assertEquals("bb", arg.getValue());
         arg = args.getArgument(1);
         assertEquals("xx", arg.getName());
-        assertEquals("xx", arg.getValue());
+        assertEquals("yy", arg.getValue());
+        arg = args.getArgument(2);
+        assertEquals("abc", arg.getName());
+        assertEquals("xyz  \r\nxyz  ", arg.getValue());
     }
 }

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=1041406&r1=1041405&r2=1041406&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Thu Dec  2 15:22:37 2010
@@ -76,6 +76,7 @@ This is internal to the workings of the 
 <h3>HTTP Samplers and Proxy</h3>
 <ul>
 <li>Bug 50178 - HeaderManager added as child of Thread Group can create concatenated HeaderManager names and OutOfMemoryException</li>
+<li>Bug 50392 - value is trimmed when sending the request in Multipart</li>
 </ul>
 
 <h3>Other Samplers</h3>



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org