jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1210275 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/config/gui/ xdocs/usermanual/component_reference.xml
Date Sun, 04 Dec 2011 23:23:17 GMT
Author: sebb
Date: Sun Dec  4 23:23:17 2011
New Revision: 1210275

Bug 51861 - Improve HTTP Request GUI to better show parameters without name (GWT RPC requests
for example) 
Fix up code so CRLF is sent after each line.


Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/
Sun Dec  4 23:23:17 2011
@@ -191,7 +191,15 @@ public class UrlConfigGui extends JPanel
         Arguments args;
         if(useRaw) {
             args = new Arguments();
-            HTTPArgument arg = new HTTPArgument("", postBodyContent.getText(), true);
+            String text = postBodyContent.getText();
+            /*
+             * Textfield uses \n (LF) to delimit lines; we need to send CRLF.
+             * Rather than change the way that arguments are processed by the
+             * samplers for raw data, it is easier to fix the data.
+             * On retrival, CRLF is converted back to LF for storage in the text field.
+             * See
+             */
+            HTTPArgument arg = new HTTPArgument("", text.replaceAll("\n","\r\n"), true);
         } else {
@@ -232,11 +240,24 @@ public class UrlConfigGui extends JPanel
      * @return {@link String}
     private static final String computePostBody(Arguments arguments) {
+        return computePostBody(arguments, false);
+    }
+    /**
+     * Compute Post body from arguments
+     * @param arguments {@link Arguments}
+     * @param crlfToLF whether to convert CRLF to LF
+     * @return {@link String}
+     */
+    private static final String computePostBody(Arguments arguments, boolean crlfToLF) {
         StringBuilder postBody = new StringBuilder();
         PropertyIterator args = arguments.iterator();
         while (args.hasNext()) {
             HTTPArgument arg = (HTTPArgument);
             String value = arg.getValue();
+            if (crlfToLF) {
+                value=value.replaceAll("\r\n", "\n"); // See modifyTestElement
+            }
         return postBody.toString();
@@ -254,7 +275,7 @@ public class UrlConfigGui extends JPanel
         boolean useRaw = el.getPropertyAsBoolean(HTTPSamplerBase.POST_BODY_RAW, HTTPSamplerBase.POST_BODY_RAW_DEFAULT);
         if(useRaw) {
-            String postBody = computePostBody(arguments);
+            String postBody = computePostBody(arguments, true); // Convert CRLF to CR, see
             postContentTabbedPane.setSelectedIndex(TAB_RAW_BODY, false);
         } else {

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sun Dec  4 23:23:17 2011
@@ -328,6 +328,8 @@ as a test plan created using a recorder 
 <b>Parameter Handling:</b><br></br>
 For the POST and PUT method, if there is no file to send, and the name(s) of the parameter(s)
are omitted,
 then the body is created by concatenating all the value(s) of the parameters.
+Note that the values are concatenated without adding any end-of-line characters.
+These can be added by using the __char() function in the value fields.
 This allows arbitrary bodies to be sent.
 The values are encoded if the encoding flag is set (versions of JMeter after 2.3).
 See also the MIME Type above how you can control the content-type request header that is
@@ -337,15 +339,20 @@ then the parameter is ignored. This allo
 (versions of JMeter after 2.3)
-<p>Since JMeter 2.5.2, you have the option to switch to Post Body when a request has
only one unnamed parameter.
-This option is useful in the following cases:
+<p>Since JMeter 2.5.2, you have the option to switch to Post Body when a request has
only unnamed parameters
+(or no parameters at all).
+This option is useful in the following cases (amongst others):
 <li>GWT RPC HTTP Request</li>
 <li>JSON REST HTTP Request</li>
 <li>XML REST HTTP Request</li>
-Note that once you leave Tree node, you cannot switch anymore to parameters tab.
+Note that once you leave the Tree node, you cannot switch back to the parameter tab unless
you clear the Post Body tab of data.
+In Post Body mode, each line will be sent with CRLF appended, apart from the last line.
+To send a CRLF after the last line of data, just ensure that there is an empty line following
+(This cannot be seen, except by noting whether the cursor can be placed on the subsequent
 <figure width="956" height="830" image="http-request-raw-single-parameter.png">Figure
1 - HTTP Request with one unnamed parameter</figure>
 <figure width="958" height="833" image="http-request-confirm-raw-body.png">Figure 2
- Confirm dialog to switch</figure>

View raw message