mstover1 2002/07/18 11:55:53
Modified: src_1/org/apache/jmeter/gui/action ExitCommand.java New.java
src_1/org/apache/jmeter/protocol/http/config/gui
UrlConfigGui.java
src_1/org/apache/jmeter/protocol/http/sampler
HTTPSampler.java
src_1/org/apache/jmeter/resources messages.properties
messages_ja.properties messages_no.properties
Log:
New Keepalive switch on HTTP Sampler GUI to help simulate HTTP1.1 vs HTTP1.0
behavior.
Contributed by Martin Ramshaw.
Revision Changes Path
1.4 +0 -1
jakarta-jmeter/src_1/org/apache/jmeter/gui/action/ExitCommand.java
Index: ExitCommand.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/action/ExitCommand.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExitCommand.java 17 May 2002 01:29:34 -0000 1.3
+++ ExitCommand.java 18 Jul 2002 18:55:53 -0000 1.4
@@ -103,7 +103,6 @@
*/
public void doAction(ActionEvent e)
{
- System.err.println("Note to self, we should really prompt to save
here... (bb)");
ActionRouter.getInstance().actionPerformed(new ActionEvent(
e.getSource(),e.getID(),CheckDirty.CHECK_DIRTY));
if(GuiPackage.getInstance().isDirty())
1.3 +0 -1 jakarta-jmeter/src_1/org/apache/jmeter/gui/action/New.java
Index: New.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/action/New.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- New.java 19 Jun 2002 19:56:20 -0000 1.2
+++ New.java 18 Jul 2002 18:55:53 -0000 1.3
@@ -103,7 +103,6 @@
*/
public void doAction(ActionEvent e)
{
- System.out.println("calling command 'New'");
ActionRouter.getInstance().actionPerformed(new ActionEvent(
e.getSource(),e.getID(),CheckDirty.CHECK_DIRTY));
GuiPackage guiPackage = GuiPackage.getInstance();
1.11 +17 -4
jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
Index: UrlConfigGui.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- UrlConfigGui.java 19 Jun 2002 19:56:20 -0000 1.10
+++ UrlConfigGui.java 18 Jul 2002 18:55:53 -0000 1.11
@@ -100,6 +100,7 @@
private static String PORT = "port";
private static String PATH = "path";
private static String FOLLOW_REDIRECTS = "follow_redirects";
+ private static String USE_KEEPALIVE = "use_keepalive";
private static String POST = "post";
private static String GET = "get";
private static String HTTP = "http";
@@ -110,6 +111,7 @@
private JTextField port;
private JTextField path;
private JCheckBox followRedirects;
+ private JCheckBox useKeepAlive;
private JRadioButton post;
private JRadioButton get;
private JRadioButton http;
@@ -161,6 +163,7 @@
element.setProperty(HTTPSampler.METHOD, (post.isSelected() ? "POST" :
"GET"));
element.setProperty(HTTPSampler.PATH, path.getText());
element.setProperty(HTTPSampler.FOLLOW_REDIRECTS, new
Boolean(followRedirects.isSelected()));
+ element.setProperty(HTTPSampler.USE_KEEPALIVE, new
Boolean(useKeepAlive.isSelected()));
element.setProperty(HTTPSampler.PROTOCOL, (http.isSelected() ? "http"
: "https"));
return element;
}
@@ -171,6 +174,7 @@
sampler.setDomain(domain.getText());
sampler.setPath(path.getText());
sampler.setFollowRedirects(followRedirects.isSelected());
+ sampler.setUseKeepAlive(useKeepAlive.isSelected());
if(port.getText().length() > 0)
{
sampler.setPort(Integer.parseInt(port.getText()));
@@ -202,6 +206,7 @@
}
path.setText((String)el.getProperty(HTTPSampler.PATH));
followRedirects.setSelected(((AbstractTestElement)el).getPropertyAsBoolean(HTTPSampler.FOLLOW_REDIRECTS));
+
useKeepAlive.setSelected(((AbstractTestElement)el).getPropertyAsBoolean(HTTPSampler.USE_KEEPALIVE));
if("http".equals(el.getProperty(HTTPSampler.PROTOCOL)))
{
http.setSelected(true);
@@ -306,9 +311,12 @@
}
/****************************************
- * !ToDoo (Method description)
+ * This method defines the Panel for the
+ * HTTP path, 'Follow Redirects' and
+ * 'Use KeepAlive' elements.
*
- *@return !ToDo (Return description)
+ *@return JPanel The Panel for the path,
+ * 'Follow Redirects' and 'Use KeepAlive' elements.
***************************************/
protected JPanel getPathPanel()
{
@@ -316,7 +324,7 @@
panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
panel.add(new JLabel(JMeterUtils.getResString("path")));
- path = new JTextField(20);
+ path = new JTextField(15);
path.setName(PATH);
panel.add(path);
@@ -326,6 +334,11 @@
// behaviour:
followRedirects.setSelected(true);
panel.add(followRedirects);
+
+ useKeepAlive = new
JCheckBox(JMeterUtils.getResString("use_keepalive"));
+ useKeepAlive.setName(USE_KEEPALIVE);
+ useKeepAlive.setSelected(true);
+ panel.add(useKeepAlive);
return panel;
}
1.18 +37 -4
jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
Index: HTTPSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- HTTPSampler.java 16 Jul 2002 17:58:03 -0000 1.17
+++ HTTPSampler.java 18 Jul 2002 18:55:53 -0000 1.18
@@ -102,6 +102,7 @@
public final static String URL = "HTTPSampler.URL";
public final static String POST = "POST";
public final static String GET = "GET";
+ public final static String USE_KEEPALIVE = "HTTPSampler.use_keepalive";
public final static String FILE_NAME = "HTTPSampler.FILE_NAME";
public final static String FILE_FIELD = "HTTPSampler.FILE_FIELD";
public final static String FILE_DATA = "HTTPSampler.FILE_DATA";
@@ -171,6 +172,16 @@
return getPropertyAsString(METHOD);
}
+ public void setUseKeepAlive(boolean value)
+ {
+ setProperty(USE_KEEPALIVE, new Boolean(value));
+ }
+
+ public boolean getUseKeepAlive()
+ {
+ return getPropertyAsBoolean(USE_KEEPALIVE);
+ }
+
public void setPort(int value)
{
setProperty(PORT,new Integer(value));
@@ -425,6 +436,18 @@
// My longer term plan is to use Apache's home grown HTTP Client, or
// maybe even HTTPUnit's classes. I'm sure both would be better than
Sun's
conn.setFollowRedirects(false);
+ // a well-bahaved browser is supposed to send 'Connection: close'
+ // with the last request to an HTTP server. Instead, most browsers
+ // leave it to the server to close the connection after their
+ // timeout period. Leave it to the JMeter user to decide.
+ if (getUseKeepAlive())
+ {
+ conn.setRequestProperty("Connection", "keep-alive");
+ }
+ else
+ {
+ conn.setRequestProperty("Connection", "close");
+ }
conn.setRequestMethod((String)url.getProperty(HTTPSampler.METHOD));
setConnectionHeaders(conn, u, getHeaderManager());
setConnectionCookie(conn, u, getCookieManager());
@@ -466,7 +489,10 @@
{
StringBuffer headerBuf = new StringBuffer();
//PrintWriter headerBytes = new PrintWriter(output);
- headerBuf.append("HTTP/1.1 ");
+
+ // either 'HTTP/1.0' or 'HTTP/1.1'
+ headerBuf.append(conn.getHeaderField(0).substring(0, 8));
+ headerBuf.append(" ");
headerBuf.append(conn.getResponseCode());
headerBuf.append(" ");
headerBuf.append(conn.getResponseMessage());
@@ -732,7 +758,14 @@
{
try
{
- conn.disconnect();
+ // the server can request that the connection be
closed,
+ // but if we requested that the server close the
connection
+ // the server should echo back our 'close' request.
+ // Otherwise, let the server disconnect the connection
+ // when its timout period is reached.
+ String connection = conn.getHeaderField("Connection");
+ if (connection == null ||
connection.equalsIgnoreCase("close"))
+ conn.disconnect();
}
catch(Exception e){}
}
1.25 +1 -0
jakarta-jmeter/src_1/org/apache/jmeter/resources/messages.properties
Index: messages.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages.properties,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- messages.properties 17 Jul 2002 01:27:46 -0000 1.24
+++ messages.properties 18 Jul 2002 18:55:53 -0000 1.25
@@ -49,6 +49,7 @@
port=Port:
path=Path:
follow_redirects=Follow Redirects
+use_keepalive=Use KeepAlive
method=Method:
default_parameters=Default Parameters
name=Name:
1.25 +1 -0
jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_ja.properties
Index: messages_ja.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_ja.properties,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- messages_ja.properties 17 Jul 2002 01:27:46 -0000 1.24
+++ messages_ja.properties 18 Jul 2002 18:55:53 -0000 1.25
@@ -41,6 +41,7 @@
port=\u30dd\u30fc\u30c8
path=\u30d1\u30b9
follow_redirects=Follow redirects [TO-DO]
+use_keepalive=Use KeepAlive
method=\u30E1\u30BD\u30C3\u30C9:
default_parameters=\u30c7\u30d5\u30a9\u30eb\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf
name=\u540D\u524D:
1.24 +1 -0
jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_no.properties
Index: messages_no.properties
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/resources/messages_no.properties,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- messages_no.properties 17 Jul 2002 01:27:46 -0000 1.23
+++ messages_no.properties 18 Jul 2002 18:55:53 -0000 1.24
@@ -49,6 +49,7 @@
port=Port:
path=Sti:
follow_redirects=Follow redirects [TO-DO]
+use_keepalive=Use KeepAlive
method=Metode:
default_parameters=Standard parametre
name=Navn:
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>