You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2017/01/19 20:35:15 UTC

svn commit: r1779521 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java

Author: fschumacher
Date: Thu Jan 19 20:35:15 2017
New Revision: 1779521

URL: http://svn.apache.org/viewvc?rev=1779521&view=rev
Log:
Clarify and correct logic of getSendParameterValuesAsPostBody, so that it only
returns true, when there are parameters and none of those have a name.

Without this requests could have a content-type header without a body.

Bugzilla Id: 60575

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1779521&r1=1779520&r2=1779521&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java Thu Jan 19 20:35:15 2017
@@ -374,25 +374,26 @@ public abstract class HTTPSamplerBase ex
     }
 
     /**
-     * Determine if none of the parameters have a name, and if that
-     * is the case, it means that the parameter values should be sent
-     * as the entity body
+     * Determine if none of the parameters have a name, and if that is the case,
+     * it means that the parameter values should be sent as the entity body
      *
-     * @return true if none of the parameters have a name specified
+     * @return {@code true} if there are parameters and none of these have a
+     *         name specified, or {@link HTTPSamplerBase#getPostBodyRaw()} returns
+     *         {@code true}
      */
     public boolean getSendParameterValuesAsPostBody() {
         if (getPostBodyRaw()) {
             return true;
         } else {
-            boolean noArgumentsHasName = true;
+            boolean hasArguments = false;
             for (JMeterProperty jMeterProperty : getArguments()) {
+                hasArguments = true;
                 HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue();
                 if (arg.getName() != null && arg.getName().length() > 0) {
-                    noArgumentsHasName = false;
-                    break;
+                    return false;
                 }
             }
-            return noArgumentsHasName;
+            return hasArguments;
         }
     }