You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2012/08/24 15:21:08 UTC

svn commit: r1376905 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java

Author: sebb
Date: Fri Aug 24 13:21:08 2012
New Revision: 1376905

URL: http://svn.apache.org/viewvc?rev=1376905&view=rev
Log:
The the case of getSendParameterValuesAsPostBody, encoding should be left to the entity handler

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

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1376905&r1=1376904&r2=1376905&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java Fri Aug 24 13:21:08 2012
@@ -914,19 +914,13 @@ public class HTTPHC4Impl extends HTTPHCA
                     PropertyIterator args = getArguments().iterator();
                     while (args.hasNext()) {
                         HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
-                        String value;
-                        if (haveContentEncoding){
-                            value = arg.getEncodedValue(contentEncoding);
-                        } else {
-                            value = arg.getEncodedValue();
-                        }
-                        postBody.append(value);
+                        postBody.append(arg.getValue());
                     }
-                    ContentType contentType = 
-                            ContentType.create(post.getFirstHeader(HTTPConstants.HEADER_CONTENT_TYPE).getValue(), contentEncoding);
-                    StringEntity requestEntity = new StringEntity(postBody.toString(), contentType);
+                    final String charset = getContentEncoding(HTTP.DEF_CONTENT_CHARSET.name());
+                    // Let StringEntity perform the encoding
+                    StringEntity requestEntity = new StringEntity(postBody.toString(), charset);
                     post.setEntity(requestEntity);
-                    postedBody.append(postBody.toString()); // TODO OK?
+                    postedBody.append(postBody.toString());
                 } else {
                     // It is a normal post request, with parameter names and values
 



Re: svn commit: r1376905 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java

Posted by sebb <se...@gmail.com>.
On 24 August 2012 14:32, Philippe Mouawad <ph...@gmail.com> wrote:
> Hello sebb,
> This commit and the previous one seem strange to me.
> Are you sure you're not breaking something ?

It looks like I have broken one of the POST unit tests.

However, I'm not sure the test makes much sense.

It ought to be possible to send an arbitrary POST body using nameless
params, but what was happening previously was that the params were
converted to www-form-encoding (space encoded as +). That only really
makes sense for content that represents a form.

> Regards
> Philippe
>
> On Fri, Aug 24, 2012 at 3:21 PM, <se...@apache.org> wrote:
>
>> Author: sebb
>> Date: Fri Aug 24 13:21:08 2012
>> New Revision: 1376905
>>
>> URL: http://svn.apache.org/viewvc?rev=1376905&view=rev
>> Log:
>> The the case of getSendParameterValuesAsPostBody, encoding should be left
>> to the entity handler
>>
>> Modified:
>>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1376905&r1=1376904&r2=1376905&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>> Fri Aug 24 13:21:08 2012
>> @@ -914,19 +914,13 @@ public class HTTPHC4Impl extends HTTPHCA
>>                      PropertyIterator args = getArguments().iterator();
>>                      while (args.hasNext()) {
>>                          HTTPArgument arg = (HTTPArgument)
>> args.next().getObjectValue();
>> -                        String value;
>> -                        if (haveContentEncoding){
>> -                            value = arg.getEncodedValue(contentEncoding);
>> -                        } else {
>> -                            value = arg.getEncodedValue();
>> -                        }
>> -                        postBody.append(value);
>> +                        postBody.append(arg.getValue());
>>                      }
>> -                    ContentType contentType =
>> -
>>  ContentType.create(post.getFirstHeader(HTTPConstants.HEADER_CONTENT_TYPE).getValue(),
>> contentEncoding);
>> -                    StringEntity requestEntity = new
>> StringEntity(postBody.toString(), contentType);
>> +                    final String charset = getContentEncoding(
>> HTTP.DEF_CONTENT_CHARSET.name());
>> +                    // Let StringEntity perform the encoding
>> +                    StringEntity requestEntity = new
>> StringEntity(postBody.toString(), charset);
>>                      post.setEntity(requestEntity);
>> -                    postedBody.append(postBody.toString()); // TODO OK?
>> +                    postedBody.append(postBody.toString());
>>                  } else {
>>                      // It is a normal post request, with parameter names
>> and values
>>
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.

Re: svn commit: r1376905 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello sebb,
This commit and the previous one seem strange to me.
Are you sure you're not breaking something ?

Regards
Philippe

On Fri, Aug 24, 2012 at 3:21 PM, <se...@apache.org> wrote:

> Author: sebb
> Date: Fri Aug 24 13:21:08 2012
> New Revision: 1376905
>
> URL: http://svn.apache.org/viewvc?rev=1376905&view=rev
> Log:
> The the case of getSendParameterValuesAsPostBody, encoding should be left
> to the entity handler
>
> Modified:
>
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>
> Modified:
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1376905&r1=1376904&r2=1376905&view=diff
>
> ==============================================================================
> ---
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> (original)
> +++
> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> Fri Aug 24 13:21:08 2012
> @@ -914,19 +914,13 @@ public class HTTPHC4Impl extends HTTPHCA
>                      PropertyIterator args = getArguments().iterator();
>                      while (args.hasNext()) {
>                          HTTPArgument arg = (HTTPArgument)
> args.next().getObjectValue();
> -                        String value;
> -                        if (haveContentEncoding){
> -                            value = arg.getEncodedValue(contentEncoding);
> -                        } else {
> -                            value = arg.getEncodedValue();
> -                        }
> -                        postBody.append(value);
> +                        postBody.append(arg.getValue());
>                      }
> -                    ContentType contentType =
> -
>  ContentType.create(post.getFirstHeader(HTTPConstants.HEADER_CONTENT_TYPE).getValue(),
> contentEncoding);
> -                    StringEntity requestEntity = new
> StringEntity(postBody.toString(), contentType);
> +                    final String charset = getContentEncoding(
> HTTP.DEF_CONTENT_CHARSET.name());
> +                    // Let StringEntity perform the encoding
> +                    StringEntity requestEntity = new
> StringEntity(postBody.toString(), charset);
>                      post.setEntity(requestEntity);
> -                    postedBody.append(postBody.toString()); // TODO OK?
> +                    postedBody.append(postBody.toString());
>                  } else {
>                      // It is a normal post request, with parameter names
> and values
>
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: svn commit: r1376905 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java

Posted by sebb <se...@gmail.com>.
On 26 August 2012 17:10, Milamber <mi...@apache.org> wrote:
>
>
> Le 24/08/2012 14:21, sebb@apache.org a ecrit :
>
>> Author: sebb
>> Date: Fri Aug 24 13:21:08 2012
>> New Revision: 1376905
>>
>> URL: http://svn.apache.org/viewvc?rev=1376905&view=rev
>> Log:
>> The the case of getSendParameterValuesAsPostBody, encoding should be left
>> to the entity handler
>>
>> Modified:
>>
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>>
>> Modified:
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1376905&r1=1376904&r2=1376905&view=diff
>>
>> ==============================================================================
>> ---
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>> (original)
>> +++
>> jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>> Fri Aug 24 13:21:08 2012
>> @@ -914,19 +914,13 @@ public class HTTPHC4Impl extends HTTPHCA
>>                       PropertyIterator args = getArguments().iterator();
>>                       while (args.hasNext()) {
>>                           HTTPArgument arg = (HTTPArgument)
>> args.next().getObjectValue();
>> -                        String value;
>> -                        if (haveContentEncoding){
>> -                            value = arg.getEncodedValue(contentEncoding);
>> -                        } else {
>> -                            value = arg.getEncodedValue();
>> -                        }
>> -                        postBody.append(value);
>> +                        postBody.append(arg.getValue());
>
>
> This update section seems introduce a regression in junit test. (missing arg
> encoding)

On further reflection (and code inspection), I agree that the change
was wrong/unnecessary.
I'll revert shortly.

Unnamed parameters are only form-encoded if the "Encode?" checkbox is selected.
Not sure that would make much sense, but provided that the box is
deselected, no conversion is done on the argument.

>
>      [java] >>>>>>>>>>>>>>>>>>>> expected:
>      [java] mytitle%2F%3Dmydescription+++%2F%5C
>      [java] ==================== actual:
>      [java] mytitle/=mydescription   /\
>      [java] <<<<<<<<<<<<<<<<<<<<
>      [java] URL=http://localhost:8182/test/somescript.jsp
>      [java] F.....................................
>
>      [java] There was 1 failure:
>      [java] 1)
> testPostRequest_BodyFromParameterValues3(org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer)junit.framework.AssertionFailedError:
> arrays have different length, expected is 35, actual is 27
>      [java]     at
> org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.checkArraysHaveSameContent(TestHTTPSamplersAgainstHttpMirrorServer.java:1239)
>      [java]     at
> org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.checkPostRequestBody(TestHTTPSamplersAgainstHttpMirrorServer.java:911)
>      [java]     at
> org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.testPostRequest_BodyFromParameterValues(TestHTTPSamplersAgainstHttpMirrorServer.java:525)
>      [java]     at
> org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.testPostRequest_BodyFromParameterValues3(TestHTTPSamplersAgainstHttpMirrorServer.java:176)
>      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
>      [java]     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>      [java]     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>      [java]     at
> junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
>      [java]     at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
>      [java]     at junit.extensions.TestSetup.run(TestSetup.java:27)
>      [java]     at org.apache.jorphan.test.AllTests.main(AllTests.java:235)
>      [java]
>
>
>
>
>>                       }
>> -                    ContentType contentType =
>> -
>> ContentType.create(post.getFirstHeader(HTTPConstants.HEADER_CONTENT_TYPE).getValue(),
>> contentEncoding);
>> -                    StringEntity requestEntity = new
>> StringEntity(postBody.toString(), contentType);
>> +                    final String charset =
>> getContentEncoding(HTTP.DEF_CONTENT_CHARSET.name());
>> +                    // Let StringEntity perform the encoding
>> +                    StringEntity requestEntity = new
>> StringEntity(postBody.toString(), charset);
>>                       post.setEntity(requestEntity);
>> -                    postedBody.append(postBody.toString()); // TODO OK?
>> +                    postedBody.append(postBody.toString());
>>                   } else {
>>                       // It is a normal post request, with parameter names
>> and values
>>
>>
>>
>> .
>>
>

Re: svn commit: r1376905 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java

Posted by Milamber <mi...@apache.org>.

Le 24/08/2012 14:21, sebb@apache.org a ecrit :
> Author: sebb
> Date: Fri Aug 24 13:21:08 2012
> New Revision: 1376905
>
> URL: http://svn.apache.org/viewvc?rev=1376905&view=rev
> Log:
> The the case of getSendParameterValuesAsPostBody, encoding should be left to the entity handler
>
> Modified:
>      jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
>
> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1376905&r1=1376904&r2=1376905&view=diff
> ==============================================================================
> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (original)
> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java Fri Aug 24 13:21:08 2012
> @@ -914,19 +914,13 @@ public class HTTPHC4Impl extends HTTPHCA
>                       PropertyIterator args = getArguments().iterator();
>                       while (args.hasNext()) {
>                           HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
> -                        String value;
> -                        if (haveContentEncoding){
> -                            value = arg.getEncodedValue(contentEncoding);
> -                        } else {
> -                            value = arg.getEncodedValue();
> -                        }
> -                        postBody.append(value);
> +                        postBody.append(arg.getValue());

This update section seems introduce a regression in junit test. (missing 
arg encoding)


      [java] >>>>>>>>>>>>>>>>>>>> expected:
      [java] mytitle%2F%3Dmydescription+++%2F%5C
      [java] ==================== actual:
      [java] mytitle/=mydescription   /\
      [java] <<<<<<<<<<<<<<<<<<<<
      [java] URL=http://localhost:8182/test/somescript.jsp
      [java] F.....................................

      [java] There was 1 failure:
      [java] 1) 
testPostRequest_BodyFromParameterValues3(org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer)junit.framework.AssertionFailedError: 
arrays have different length, expected is 35, actual is 27
      [java]     at 
org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.checkArraysHaveSameContent(TestHTTPSamplersAgainstHttpMirrorServer.java:1239)
      [java]     at 
org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.checkPostRequestBody(TestHTTPSamplersAgainstHttpMirrorServer.java:911)
      [java]     at 
org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.testPostRequest_BodyFromParameterValues(TestHTTPSamplersAgainstHttpMirrorServer.java:525)
      [java]     at 
org.apache.jmeter.protocol.http.sampler.TestHTTPSamplersAgainstHttpMirrorServer.testPostRequest_BodyFromParameterValues3(TestHTTPSamplersAgainstHttpMirrorServer.java:176)
      [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
      [java]     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java]     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [java]     at 
junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
      [java]     at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
      [java]     at junit.extensions.TestSetup.run(TestSetup.java:27)
      [java]     at org.apache.jorphan.test.AllTests.main(AllTests.java:235)
      [java]




>                       }
> -                    ContentType contentType =
> -                            ContentType.create(post.getFirstHeader(HTTPConstants.HEADER_CONTENT_TYPE).getValue(), contentEncoding);
> -                    StringEntity requestEntity = new StringEntity(postBody.toString(), contentType);
> +                    final String charset = getContentEncoding(HTTP.DEF_CONTENT_CHARSET.name());
> +                    // Let StringEntity perform the encoding
> +                    StringEntity requestEntity = new StringEntity(postBody.toString(), charset);
>                       post.setEntity(requestEntity);
> -                    postedBody.append(postBody.toString()); // TODO OK?
> +                    postedBody.append(postBody.toString());
>                   } else {
>                       // It is a normal post request, with parameter names and values
>
>
>
> .
>