You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2006/05/15 23:50:31 UTC
svn commit: r406751 -
/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
Author: sebb
Date: Mon May 15 14:50:30 2006
New Revision: 406751
URL: http://svn.apache.org/viewcvs?rev=406751&view=rev
Log:
Add parameters to requestEntity otherwise they are lost
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?rev=406751&r1=406750&r2=406751&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java Mon May 15 14:50:30 2006
@@ -56,6 +56,7 @@
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
+import org.apache.commons.httpclient.methods.multipart.StringPart;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.jmeter.JMeter;
@@ -184,21 +185,28 @@
* if an I/O exception occurs
*/
private void sendPostData(PostMethod post) throws IOException {
- PropertyIterator args = getArguments().iterator();
- while (args.hasNext()) {
- Argument arg = (Argument) args.next().getObjectValue();
- post.addParameter(arg.getName(), arg.getValue());
- }
// If filename was specified then send the post using multipart syntax
String filename = getFilename();
if ((filename != null) && (filename.trim().length() > 0)) {
- File input = new File(filename);
- Part[] parts = {
+ int argc = getArguments().getArgumentCount();
+ Part[] parts = new Part[argc+1];
+ PropertyIterator args = getArguments().iterator();
+ int i = 0;
+ while (args.hasNext()) {
+ Argument arg = (Argument) args.next().getObjectValue();
+ parts[i++] = new StringPart(arg.getName(), arg.getValue());
+ }
+ File input = new File(filename);
//TODO should allow charset to be defined ...
- new FilePart(getFileField(), input, getMimetype(), "UTF-8" )//$NON-NLS-1$
- };
- post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
- }
+ parts[i]= new FilePart(getFileField(), input, getMimetype(), "UTF-8" );//$NON-NLS-1$
+ post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
+ } else {
+ PropertyIterator args = getArguments().iterator();
+ while (args.hasNext()) {
+ Argument arg = (Argument) args.next().getObjectValue();
+ post.addParameter(arg.getName(), arg.getValue());
+ }
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org