Hello everybody.
When a multipart form (where file input is empty) is
sent to jmeter proxy, the request sampler is
successfully created but the web server gets a request
without parameters. So i've modified PostWriter. Now,
every time that PostWriter receives a multipart form,
it will send a multipart form (even when file input is
empty) to the web server...
What do you think about this ? Is it correct ?
Thanks in advance.
______________________________________________________________________
Yahoo! Mail - O melhor e-mail do Brasil! Abra sua conta agora:
http://br.yahoo.com/info/mail.html
Index: src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java,v
retrieving revision 1.23
diff -u -r1.23 HttpRequestHdr.java
--- src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java 12 Feb
2004 01:19:53 -0000 1.23
+++ src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java 25 Feb
2004 15:36:13 -0000
@@ -187,10 +187,13 @@
// Damn! A whole new GUI just to instantiate a test element?
// Isn't there a beter way?
HttpTestSampleGui tempGui = new HttpTestSampleGui();
- tempGui.configure(createSampler());
+ HTTPSampler tempSampler=createSampler();
+ tempGui.configure(tempSampler);
HTTPSampler result = (HTTPSampler) tempGui.createTestElement();
result.setFollowRedirects(false);
result.setUseKeepAlive(true);
+ result.setMultipart(tempSampler.isMultipart());
+
return result;
}
@@ -255,6 +258,8 @@
if ((urlConfig = isMultipart(getContentType())) != null)
{
urlConfig.parseArguments(postData);
+ log.debug("Request is multipart");
+ sampler.setMultipart(true);
sampler.setArguments(urlConfig.getArguments());
sampler.setFileField(urlConfig.getFileFieldName());
sampler.setFilename(urlConfig.getFilename());
@@ -262,7 +267,9 @@
}
else
{
+ log.debug("Request is NOT multipart");
sampler.parseArguments(postData);
+ sampler.setMultipart(false);
}
return sampler;
}
Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
retrieving revision 1.87
diff -u -r1.87 HTTPSampler.java
--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java 22 Feb
2004 19:21:41 -0000 1.87
+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java 25 Feb
2004 15:36:16 -0000
@@ -98,6 +98,7 @@
public final static String PATH= "HTTPSampler.path";
public final static String FOLLOW_REDIRECTS= "HTTPSampler.follow_redirects";
public final static String PROTOCOL= "HTTPSampler.protocol";
+ public final static String IS_MULTIPART = "HTTPSampler.is_multipart";
public final static String DEFAULT_PROTOCOL= "http";
public final static String URL= "HTTPSampler.URL";
public final static String POST= "POST";
@@ -212,6 +213,14 @@
{
return protocol;
}
+ }
+
+ public void setMultipart(boolean value) {
+ setProperty(new BooleanProperty(IS_MULTIPART, value));
+ }
+
+ public boolean isMultipart() {
+ return getPropertyAsBoolean(IS_MULTIPART);
}
/**
Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java,v
retrieving revision 1.12
diff -u -r1.12 PostWriter.java
--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java 12 Feb
2004 00:29:49 -0000 1.12
+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/PostWriter.java 25 Feb
2004 15:36:17 -0000
@@ -31,6 +31,9 @@
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.testelement.property.PropertyIterator;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
/**
* @author Michael Stover
* @version $Revision: 1.12 $
@@ -44,15 +47,21 @@
//protected static int fudge = -20;
protected static final String encoding = "iso-8859-1";
+
+ transient private static Logger log = LoggingManager.getLoggerForClass();
+
/**
* Send POST data from Entry to the open connection.
*/
public void sendPostData(URLConnection connection, HTTPSampler sampler)
throws IOException
{
+ log.debug("sendPostData(): sampler.isMultipart() " + sampler.isMultipart());
+ log.debug("sendPostData(): sampler.getFilename() " + sampler.getFilename());
// If filename was specified then send the post using multipart syntax
String filename = sampler.getFilename();
- if ((filename != null) && (filename.trim().length() > 0))
+ //if ((filename != null) && (filename.trim().length() > 0))
+ if (sampler.isMultipart())
{
OutputStream out = connection.getOutputStream();
//new FileOutputStream("c:\\data\\experiment.txt");
@@ -122,7 +131,10 @@
private InputStream getFileStream(String filename) throws IOException
{
- return new BufferedInputStream(new FileInputStream(filename));
+ if (filename!=null && filename.trim().length()>0)
+ return new BufferedInputStream(new FileInputStream(filename));
+ else
+ return new BufferedInputStream(new java.io.StringBufferInputStream(""));
}
/* NOTUSED
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]