In the HTTP Request GUI, there is a checkbox for each parameter value, "Encode?". Even if this is unchecked, the HTTP Request using HTTP Client urlencodes the value when doing a HTTP POST request, which is incorrect. The reason is that the HTTPClient PostMethod class addParameter method, which is called in HTTPSampler2.java, assumes that the value is not alread URL encoded. So the HTTPClient PostMethod always urlencodes the parameter names and values before they are sent. So if you have a parameter named test, with value "%2Ftest%3D", and do a POST request, the POST body will contain "%252Ftest%253D", because the already urlencoded value is urlencoded once more. If you are using a HTTP Request (i.e the HTTPSampler.java), you will see that "%2Ftest%3D" is sent, because the getQueryString of HTTPSamplerBase takes into consideration the value of httpargument.isAlwaysEncoded().
Created attachment 19986 [details] Suggested patch This patch urldecodes parameter value if the httpargument.isAlwaysEncode is false, so that when it is added to the httpclient postmethod, where it is urlencoded, the value will be correct. There is also an commented out section, which uses the HTTPSamplerBase.getQueryString to construct the post body. If this alternative is used, then HTTPSampler and HTTPSampler2 will always send the same POST body. I do not know which alternative you prefer. The patch also contains more unit tests for TestHTTPSamplersAgainstHttpMirrorServer, it contains the new tests suggested in patch for bug 42139, plus some more, to expose this bug. So if this patch for this bug is applied, then bug 42139 should just be closed. If only the unit tests are applied, then you will see that one test will fail for HTTPSampler2, the one with titleValue = "%2FwEPDwULLTE2MzM2OTA0NTYPZBYCAgMPZ%2FrA%2B8DZ2dnZ2dnZ2d%2FGNDar6OshPwdJc%3D";
Created attachment 19987 [details] Updated suggested patch I just had to remove to System.out.println lines, which accidential made it into my first suggested patch.
Thanks! Applied to SVN r530147 - I ignored the TestHTTPSamplersAgainstHttpMirrorServer part as I'd already applied bug 42139.
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1913