jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1210275 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java 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

URL: http://svn.apache.org/viewvc?rev=1210275&view=rev
Log:
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/UrlConfigGui.java
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java?rev=1210275&r1=1210274&r2=1210275&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
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);
             arg.setAlwaysEncoded(false);
             args.addArgument(arg);
         } 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) args.next().getObjectValue();
             String value = arg.getValue();
+            if (crlfToLF) {
+                value=value.replaceAll("\r\n", "\n"); // See modifyTestElement
+            }
             postBody.append(value);
         }
         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
modifyTestElement
             postBodyContent.setText(postBody);   
             postContentTabbedPane.setSelectedIndex(TAB_RAW_BODY, false);
         } else {

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1210275&r1=1210274&r2=1210275&view=diff
==============================================================================
--- 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
sent.
@@ -337,15 +339,20 @@ then the parameter is ignored. This allo
 (versions of JMeter after 2.3)
 </p>
 <br/>
-<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):
 <ul>
 <li>GWT RPC HTTP Request</li>
 <li>JSON REST HTTP Request</li>
 <li>XML REST HTTP Request</li>
-<li>...</li>
 </ul>
-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.
+</p>
+<p>
+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
it.
+(This cannot be seen, except by noting whether the cursor can be placed on the subsequent
line.)
 </p>
 <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>



Mime
View raw message