Le 24/08/2012 14:21, [email protected] 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
.