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 ms...@apache.org on 2002/04/24 18:11:13 UTC
cvs commit: jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/proxy HttpRequestHdr.java Proxy.java
mstover1 02/04/24 09:11:13
Modified: src_1/org/apache/jmeter/protocol/http/config
MultipartUrlConfig.java UrlConfig.java
src_1/org/apache/jmeter/protocol/http/control/gui
HttpTestSampleGui.java
src_1/org/apache/jmeter/protocol/http/proxy
HttpRequestHdr.java Proxy.java
Added: src_1/org/apache/jmeter/protocol/http/config/gui
MultipartUrlConfigGui.java UrlConfigGui.java
Log:
modifications to proxy process
Revision Changes Path
1.2 +7 -10 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java
Index: MultipartUrlConfig.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/MultipartUrlConfig.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MultipartUrlConfig.java 19 Apr 2002 02:18:11 -0000 1.1
+++ MultipartUrlConfig.java 24 Apr 2002 16:11:13 -0000 1.2
@@ -59,6 +59,7 @@
import org.apache.jmeter.config.ConfigElement;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
/**
* Title: JMeter
@@ -73,10 +74,6 @@
{
public static String MULTIPART_FORM = "multipart/form-data";
-
- private static String FILENAME = "filename";
- private static String FIELDNAME = "fieldname";
- private static String MIMETYPE = "mimetype";
private static String BOUNDARY = "boundary";
public MultipartUrlConfig()
@@ -118,32 +115,32 @@
public void setFilename(String filename)
{
- setProperty(FILENAME,filename);
+ setProperty(HTTPSampler.FILE_NAME,filename);
}
public String getFilename()
{
- return (String)this.getProperty(FILENAME);
+ return (String)this.getProperty(HTTPSampler.FILE_NAME);
}
public void setFileFieldName(String name)
{
- setProperty(FIELDNAME,name);
+ setProperty(HTTPSampler.FILE_FIELD,name);
}
public String getFileFieldName()
{
- return (String)this.getProperty(FIELDNAME);
+ return (String)this.getProperty(HTTPSampler.FILE_FIELD);
}
public void setMimeType(String type)
{
- setProperty(MIMETYPE,type);
+ setProperty(HTTPSampler.FILE_MIMETYPE,type);
}
public String getMimeType()
{
- return (String)this.getProperty(MIMETYPE);
+ return (String)this.getProperty(HTTPSampler.FILE_MIMETYPE);
}
public InputStream getFileStream() throws IOException
1.2 +24 -55 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/UrlConfig.java
Index: UrlConfig.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/UrlConfig.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UrlConfig.java 19 Apr 2002 02:18:11 -0000 1.1
+++ UrlConfig.java 24 Apr 2002 16:11:13 -0000 1.2
@@ -60,6 +60,7 @@
import org.apache.jmeter.config.*;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import java.io.*;
/**
@@ -71,56 +72,24 @@
* the value you specify here.
*
*@author Michael Stover
- *@created $Date: 2002/04/19 02:18:11 $
- *@version $Revision: 1.1 $
+ *@created $Date: 2002/04/24 16:11:13 $
+ *@version $Revision: 1.2 $
*/
public class UrlConfig extends AbstractTestElement implements Serializable
{
- /**
- * Description of the Field
- */
- public final static String DOMAIN = "domain";
- /**
- * Description of the Field
- */
- public final static String PORT = "port";
- /**
- * Description of the Field
- */
- public final static String PATH = "path";
- /**
- * Description of the Field
- */
- public final static String METHOD = "method";
- /**
- * Description of the Field
- */
- public final static String ARGUMENTS = "arguments";
- /**
- * Description of the Field
- */
- public final static String POST = "POST";
- /**
- * Description of the Field
- */
- public final static String PROTOCOL = "PROTOCOL";
- /**
- * Description of the Field
- */
- public final static String GET = "GET";
/**
* Constructor for the UrlConfig object
*/
public UrlConfig()
{
- this.setProperty(ARGUMENTS, new Arguments());
+ this.setProperty(HTTPSampler.ARGUMENTS, new Arguments());
}
public void setArguments(Arguments args)
{
- setProperty(ARGUMENTS,args);
+ setProperty(HTTPSampler.ARGUMENTS,args);
}
/**
@@ -130,7 +99,7 @@
*/
public void setMethod(String meth)
{
- setProperty(METHOD, meth);
+ setProperty(HTTPSampler.METHOD, meth);
}
/**
@@ -140,12 +109,12 @@
*/
public void setProtocol(String protocol)
{
- setProperty(PROTOCOL, protocol);
+ setProperty(HTTPSampler.PROTOCOL, protocol);
}
public void removeArguments()
{
- setProperty(ARGUMENTS,new Arguments());
+ setProperty(HTTPSampler.ARGUMENTS,new Arguments());
}
/**
@@ -155,10 +124,10 @@
*/
public void setPort(int port)
{
- setProperty(PORT, new Integer(port));
+ setProperty(HTTPSampler.PORT, new Integer(port));
if (port == 0)
{
- removeProperty(PORT);
+ removeProperty(HTTPSampler.PORT);
}
}
@@ -173,12 +142,12 @@
if (index >= 0)
{
String queryString = path.substring(index + 1);
- setProperty(PATH, path.substring(0, index));
+ setProperty(HTTPSampler.PATH, path.substring(0, index));
parseArguments(queryString);
}
else
{
- setProperty(PATH, path);
+ setProperty(HTTPSampler.PATH, path);
}
}
@@ -195,7 +164,7 @@
*/
public void setDomain(String domain)
{
- setProperty(DOMAIN, domain);
+ setProperty(HTTPSampler.DOMAIN, domain);
}
/**
@@ -208,7 +177,7 @@
{
String pathAndQuery = null;
- if (this.getMethod().equals(this.GET) && getQueryString().length() > 0)
+ if (this.getMethod().equals(HTTPSampler.GET) && getQueryString().length() > 0)
{
pathAndQuery = this.getPath() + "?" + getQueryString();
}
@@ -228,7 +197,7 @@
}
else
{
- return new URL(getProtocol(), (String) getProperty(DOMAIN), getPort(),
+ return new URL(getProtocol(), (String) getProperty(HTTPSampler.DOMAIN), getPort(),
pathAndQuery);
}
}
@@ -240,10 +209,10 @@
*/
public int getPort()
{
- Object port = getProperty(PORT);
+ Object port = getProperty(HTTPSampler.PORT);
if (port == null)
{
- removeProperty(PORT);
+ removeProperty(HTTPSampler.PORT);
return 0;
}
else if (port instanceof Integer)
@@ -253,7 +222,7 @@
else if (port instanceof String)
{
Integer intPort = new Integer((String) port);
- setProperty(PORT, intPort);
+ setProperty(HTTPSampler.PORT, intPort);
return intPort.intValue();
}
return 0;
@@ -266,7 +235,7 @@
*/
public String getProtocol()
{
- String protocol = (String) getProperty(PROTOCOL);
+ String protocol = (String) getProperty(HTTPSampler.PROTOCOL);
return protocol;
}
@@ -277,7 +246,7 @@
*/
public String getPath()
{
- String path = (String)getProperty(PATH);
+ String path = (String)getProperty(HTTPSampler.PATH);
if (path == null)
{
path = "/";
@@ -293,7 +262,7 @@
*/
public String getDomain()
{
- return (String) getProperty(DOMAIN);
+ return (String) getProperty(HTTPSampler.DOMAIN);
}
/**
@@ -303,7 +272,7 @@
*/
public String getMethod()
{
- return (String) getProperty(METHOD);
+ return (String) getProperty(HTTPSampler.METHOD);
}
/**
@@ -313,7 +282,7 @@
*/
public Arguments getArguments()
{
- return (Arguments) getProperty(this.ARGUMENTS);
+ return (Arguments) getProperty(HTTPSampler.ARGUMENTS);
}
/**
@@ -417,7 +386,7 @@
{
UrlConfig config = new UrlConfig();
config.setProtocol("http");
- config.setMethod(GET);
+ config.setMethod(HTTPSampler.GET);
config.addArgument("param1","value1");
config.setPath("/index.html");
config.setDomain("www.apache.org");
1.1 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/gui/MultipartUrlConfigGui.java
Index: MultipartUrlConfigGui.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache JMeter", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jmeter.protocol.http.config.gui;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.border.*;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.gui.*;
import org.apache.jmeter.gui.NamePanel;
import org.apache.jmeter.gui.util.FileDialoger;
import org.apache.jmeter.gui.util.VerticalLayout;
import org.apache.jmeter.protocol.http.config.MultipartUrlConfig;
import org.apache.jmeter.protocol.http.sampler.*;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import java.util.Collection;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created $Date: 2002/04/24 16:11:13 $
*@version 1.0
***************************************/
public class MultipartUrlConfigGui extends UrlConfigGui implements ActionListener
{
JTextField filenameField;
JTextField paramNameField;
JTextField mimetypeField;
JLabel filenameLabel;
JLabel paramNameLabel;
JLabel mimetypeLabel;
JButton browseFileButton;
private static String FILENAME = "filename";
private static String BROWSE = "browse";
private static String PARAMNAME = "paramname";
private static String MIMETYPE = "mimetype";
/****************************************
* !ToDo (Constructor description)
***************************************/
public MultipartUrlConfigGui()
{
this(true);
}
public Collection getMenuCategories()
{
return null;
}
/****************************************
* !ToDo (Constructor description)
*
*@param displayName !ToDo (Parameter description)
***************************************/
public MultipartUrlConfigGui(boolean displayName)
{
super(displayName);
setName(getStaticLabel());
}
/****************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public TestElement createTestElement()
{
TestElement ce = super.createTestElement();
configureTestElement(ce);
ce.setProperty(HTTPSampler.MIMETYPE, mimetypeField.getText());
ce.setProperty(HTTPSampler.FILE_NAME, filenameField.getText());
ce.setProperty(HTTPSampler.FILE_FIELD, paramNameField.getText());
return ce;
}
public void configureSampler(HTTPSampler sampler)
{
sampler.setMimetype(mimetypeField.getText());
sampler.setFileField(paramNameField.getText());
sampler.setFilename(filenameField.getText());
super.configureSampler(sampler);
}
/****************************************
* !ToDo (Method description)
*
*@param el !ToDo (Parameter description)
***************************************/
public void configure(TestElement el)
{
super.configure(el);
mimetypeField.setText((String)el.getProperty(HTTPSampler.MIMETYPE));
filenameField.setText((String)el.getProperty(HTTPSampler.FILE_NAME));
paramNameField.setText((String)el.getProperty(HTTPSampler.FILE_FIELD));
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String getStaticLabel()
{
return JMeterUtils.getResString("url_multipart_config_title");
}
/****************************************
* !ToDo (Method description)
***************************************/
public void updateGui() { }
/****************************************
* !ToDo (Method description)
*
*@param e !ToDo (Parameter description)
***************************************/
public void actionPerformed(ActionEvent e)
{
String name = e.getActionCommand();
if(name.equals(BROWSE))
{
JFileChooser chooser = FileDialoger.promptToOpenFile();
File file = chooser.getSelectedFile();
if(file != null)
{
filenameField.setText(file.getPath());
}
}
}
/****************************************
* !ToDo (Method description)
***************************************/
protected void init()
{
this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
// WEB SERVER PANEL
JPanel webServerPanel = new JPanel();
webServerPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
webServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("web_server")));
webServerPanel.add(getDomainPanel());
webServerPanel.add(getPortPanel());
// WEB REQUEST PANEL
JPanel webRequestPanel = new JPanel();
webRequestPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
webRequestPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("web_request")));
webRequestPanel.add(getProtocolAndMethodPanel());
webRequestPanel.add(getPathPanel());
webRequestPanel.add(getParameterPanel());
webRequestPanel.add(getFilePanel());
// If displayName is TRUE, then this GUI is not embedded in another GUI.
if(displayName)
{
// MAIN PANEL
JPanel mainPanel = new JPanel();
Border margin = new EmptyBorder(10, 10, 5, 10);
mainPanel.setBorder(margin);
mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
// TITLE
JLabel panelTitleLabel = new JLabel(JMeterUtils.getResString("url_full_config_title"));
Font curFont = panelTitleLabel.getFont();
int curFontSize = curFont.getSize();
curFontSize += 4;
panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
mainPanel.add(panelTitleLabel);
// NAME
mainPanel.add(getNamePanel());
mainPanel.add(webServerPanel);
mainPanel.add(webRequestPanel);
this.add(mainPanel);
}
else
{// Embed this GUI in the parent GUI
this.add(webServerPanel);
this.add(webRequestPanel);
}
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
protected JPanel getFilePanel()
{
// FILE PANEL (all main components are add to this panel)
JPanel filePanel = new JPanel();
filePanel.setLayout(new VerticalLayout(1, VerticalLayout.LEFT));
filePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
// SEND FILE LABEL
JLabel sendFileLabel = new JLabel(JMeterUtils.getResString("send_file"));
filePanel.add(sendFileLabel);
// FILENAME PANEL (contains filename label and text field and Browse button)
JPanel filenamePanel = new JPanel();
filenamePanel.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
// --- FILENAME LABEL
filenameLabel = new JLabel(JMeterUtils.getResString("send_file_filename_label"));
filenameLabel.setEnabled(true);
// --- FILENAME TEXT FIELD
filenameField = new JTextField(15);
filenameField.setEnabled(true);
filenameField.setName(FILENAME);
// --- BROWSE BUTTON
browseFileButton = new JButton(JMeterUtils.getResString("send_file_browse"));
browseFileButton.setEnabled(true);
browseFileButton.setActionCommand(BROWSE);
browseFileButton.addActionListener(this);
filenamePanel.add(filenameLabel);
filenamePanel.add(filenameField);
filenamePanel.add(browseFileButton);
// PARAM NAME PANEL (contains param name label and text field)
JPanel paramNamePanel = new JPanel();
paramNamePanel.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
// --- PARAM NAME LABEL
paramNameLabel = new JLabel(JMeterUtils.getResString("send_file_param_name_label"));
paramNameLabel.setEnabled(true);
// --- PARAM NAME TEXT FIELD
paramNameField = new JTextField(15);
paramNameField.setName(PARAMNAME);
paramNameField.setEnabled(true);
paramNamePanel.add(paramNameLabel);
paramNamePanel.add(paramNameField);
// MIME TYPE PANEL (contains mime type label and text field)
JPanel mimePanel = new JPanel();
mimePanel.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
// --- MIME TYPE LABEL
mimetypeLabel = new JLabel(JMeterUtils.getResString("send_file_mime_label"));
mimetypeLabel.setEnabled(true);
// --- MIME TYPE TEXT FIELD
mimetypeField = new JTextField(15);
mimetypeField.setEnabled(true);
mimetypeField.setName(MIMETYPE);
mimePanel.add(mimetypeLabel);
mimePanel.add(mimetypeField);
filePanel.add(filenamePanel);
filePanel.add(paramNamePanel);
filePanel.add(mimePanel);
return filePanel;
}
}
1.1 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/config/gui/UrlConfigGui.java
Index: UrlConfigGui.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache JMeter", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jmeter.protocol.http.config.gui;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.config.gui.AbstractConfigGui;
import org.apache.jmeter.config.gui.ArgumentsPanel;
import org.apache.jmeter.gui.*;
import org.apache.jmeter.gui.util.VerticalLayout;
import org.apache.jmeter.protocol.http.config.UrlConfig;
import org.apache.jmeter.protocol.http.sampler.*;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
/****************************************
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
*@created $Date: 2002/04/24 16:11:13 $
*@version 1.0
***************************************/
public class UrlConfigGui extends AbstractConfigGui
{
/****************************************
* !ToDo (Field description)
***************************************/
protected boolean displayName = true;
/****************************************
* !ToDo (Field description)
***************************************/
protected ArgumentsPanel argsPanel;
/****************************************
* !ToDo (Field description)
***************************************/
protected NamePanel namePanel;
private static String DOMAIN = "domain";
private static String PORT = "port";
private static String PATH = "path";
private static String POST = "post";
private static String GET = "get";
private static String HTTP = "http";
private static String HTTPS = "https";
private static String SEND_PARAM = "sendparam";
private JTextField domain;
private JTextField port;
private JTextField path;
private JRadioButton post;
private JRadioButton get;
private JRadioButton http;
private JRadioButton https;
/****************************************
* !ToDo (Constructor description)
***************************************/
public UrlConfigGui()
{
this(true);
}
/****************************************
* !ToDo (Constructor description)
*
*@param display !ToDo (Parameter description)
***************************************/
public UrlConfigGui(boolean display)
{
namePanel = new NamePanel();
displayName = display;
init();
setName(getStaticLabel());
}
/****************************************
* !ToDo (Method description)
*
*@param name !ToDo (Parameter description)
***************************************/
public void setName(String name)
{
super.setName(name);
namePanel.setName(name);
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String getName()
{
return namePanel.getName();
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public String getStaticLabel()
{
return JMeterUtils.getResString("url_config_title");
}
/****************************************
* !ToDo (Method description)
*
*@return !ToDo (Return description)
***************************************/
public TestElement createTestElement()
{
ConfigTestElement element = new ConfigTestElement();
this.configureTestElement(element);
element.setProperty(HTTPSampler.ARGUMENTS, argsPanel.createTestElement());
element.setProperty(HTTPSampler.DOMAIN, domain.getText());
element.setProperty(HTTPSampler.PORT, port.getText());
element.setProperty(HTTPSampler.METHOD, (post.isSelected() ? "POST" : "GET"));
element.setProperty(HTTPSampler.PATH, path.getText());
element.setProperty(HTTPSampler.PROTOCOL, (http.isSelected() ? "http" : "https"));
return element;
}
public void configureSampler(HTTPSampler sampler)
{
sampler.setArguments((Arguments)argsPanel.createTestElement());
sampler.setDomain(domain.getText());
sampler.setPath(path.getText());
if(port.getText().length() > 0)
{
sampler.setPort(Integer.parseInt(port.getText()));
}
sampler.setMethod((post.isSelected() ? "POST" : "GET"));
sampler.setProtocol((http.isSelected() ? "http" : "https"));
}
/****************************************
* !ToDo (Method description)
*
*@param el !ToDo (Parameter description)
***************************************/
public void configure(TestElement el)
{
setName((String)el.getProperty(TestElement.NAME));
argsPanel.configure((TestElement)el.getProperty(HTTPSampler.ARGUMENTS));
domain.setText((String)el.getProperty(HTTPSampler.DOMAIN));
port.setText((String)el.getPropertyAsString(HTTPSampler.PORT));
if(el.getProperty(HTTPSampler.METHOD).equals("POST"))
{
post.setSelected(true);
get.setSelected(false);
}
else
{
get.setSelected(true);
post.setSelected(false);
}
path.setText((String)el.getProperty(HTTPSampler.PATH));
if(el.getProperty(HTTPSampler.PROTOCOL).equals("http"))
{
http.setSelected(true);
https.setSelected(false);
}
else
{
https.setSelected(true);
http.setSelected(false);
}
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
protected NamePanel getNamePanel()
{
return namePanel;
}
/****************************************
* !ToDo (Method description)
***************************************/
protected void init()
{
this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
JPanel webServerPanel = new JPanel();
webServerPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
webServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("web_server")));
webServerPanel.add(getDomainPanel());
webServerPanel.add(getPortPanel());
JPanel webRequestPanel = new JPanel();
webRequestPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
webRequestPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("web_request")));
webRequestPanel.add(getProtocolAndMethodPanel());
webRequestPanel.add(getPathPanel());
webRequestPanel.add(getParameterPanel());
if(displayName)
{
// MAIN PANEL
JPanel mainPanel = new JPanel();
Border margin = new EmptyBorder(10, 10, 5, 10);
mainPanel.setBorder(margin);
mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
// TITLE
JLabel panelTitleLabel = new JLabel(JMeterUtils.getResString("url_config_title"));
Font curFont = panelTitleLabel.getFont();
int curFontSize = curFont.getSize();
curFontSize += 4;
panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
mainPanel.add(panelTitleLabel);
// NAME
mainPanel.add(getNamePanel());
mainPanel.add(webServerPanel);
mainPanel.add(webRequestPanel);
this.add(mainPanel);
}
else
{
this.add(webServerPanel);
this.add(webRequestPanel);
}
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
protected JPanel getPortPanel()
{
JPanel portP = new JPanel();
portP.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
portP.add(new JLabel(JMeterUtils.getResString("web_server_port")));
port = new JTextField(6);
port.setName(PORT);
portP.add(port);
return portP;
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
protected JPanel getDomainPanel()
{
JPanel domainP = new JPanel();
domainP.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
domainP.add(new JLabel(JMeterUtils.getResString("web_server_domain")));
domain = new JTextField(20);
domain.setName(DOMAIN);
domainP.add(domain);
return domainP;
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
protected JPanel getPathPanel()
{
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
panel.add(new JLabel(JMeterUtils.getResString("path")));
path = new JTextField(20);
path.setName(PATH);
panel.add(path);
return panel;
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
protected JPanel getProtocolAndMethodPanel()
{
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
panel.add(new JLabel(JMeterUtils.getResString("protocol")));
panel.add(Box.createRigidArea(new Dimension(5, 0)));
// PROTOCOL
http = new JRadioButton(JMeterUtils.getResString("url_config_http"));
https = new JRadioButton(JMeterUtils.getResString("url_config_https"));
ButtonGroup protocolButtonGroup = new ButtonGroup();
protocolButtonGroup.add(http);
protocolButtonGroup.add(https);
http.setSelected(true);
panel.add(http);
panel.add(https);
panel.add(Box.createRigidArea(new Dimension(20, 0)));
// METHOD
post = new JRadioButton(JMeterUtils.getResString("url_config_post"));
get = new JRadioButton(JMeterUtils.getResString("url_config_get"));
ButtonGroup methodButtonGroup = new ButtonGroup();
methodButtonGroup.add(post);
methodButtonGroup.add(get);
panel.add(new JLabel(JMeterUtils.getResString("method")));
panel.add(Box.createRigidArea(new Dimension(5, 0)));
post.setSelected(true);
panel.add(get);
panel.add(post);
return panel;
}
/****************************************
* !ToDoo (Method description)
*
*@return !ToDo (Return description)
***************************************/
protected JPanel getParameterPanel()
{
argsPanel = new ArgumentsPanel();
return argsPanel;
}
}
1.3 +2 -2 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java
Index: HttpTestSampleGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/control/gui/HttpTestSampleGui.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpTestSampleGui.java 19 Apr 2002 02:08:48 -0000 1.2
+++ HttpTestSampleGui.java 24 Apr 2002 16:11:13 -0000 1.3
@@ -72,7 +72,7 @@
* Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
*
*@author Michael Stover
- *@created $Date: 2002/04/19 02:08:48 $
+ *@created $Date: 2002/04/24 16:11:13 $
*@version 1.0
***************************************/
@@ -99,7 +99,7 @@
super.configure(element);
urlConfigGui.configure(element);
String testClass = (String)element.getProperty(TestElement.TEST_CLASS);
- if(testClass.endsWith("Full"))
+ if(testClass != null && testClass.endsWith("Full"))
{
getImages.setSelected(true);
}
1.3 +62 -62 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
Index: HttpRequestHdr.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpRequestHdr.java 19 Apr 2002 02:08:49 -0000 1.2
+++ HttpRequestHdr.java 24 Apr 2002 16:11:13 -0000 1.3
@@ -22,8 +22,8 @@
* !ToDo (Class description)
*
*@author $Author: mstover1 $
- *@created $Date: 2002/04/19 02:08:49 $
- *@version $Revision: 1.2 $
+ *@created $Date: 2002/04/24 16:11:13 $
+ *@version $Revision: 1.3 $
***************************************/
public class HttpRequestHdr
{
@@ -60,82 +60,82 @@
* Parses a http header from a stream.
*
*@param in The stream to parse.
- *@return true if parsing sucsessfull.
+ *@return Array of bytes from client.
***************************************/
- public boolean parse(InputStream in)
+ public byte[] parse(InputStream in) throws IOException
{
+ boolean inHeaders = true;
+ int readLength = 0;
+ int dataLength = 0;
String CR = "\r\n";
-
- /*
- * Read by lines
- */
- BufferedReader lines;
- StringTokenizer tz;
- try
+ boolean first = true;
+ ByteArrayOutputStream clientRequest = new ByteArrayOutputStream();
+ ByteArrayOutputStream line = new ByteArrayOutputStream();
+ int x;
+ while((inHeaders || readLength < dataLength) && ((x = in.read()) != -1))
{
- lines = new BufferedReader(new InputStreamReader(new DataInputStream(in)));
- String firstLine = lines.readLine();
- tz = new StringTokenizer(firstLine);
- }
- catch(Exception e)
- {
- return false;
+ line.write(x);
+ clientRequest.write(x);
+ if(inHeaders && (byte)x == (byte)'\n')
+ {
+ if(line.size() < 3)
+ {
+ inHeaders = false;
+ }
+ if(first)
+ {
+ parseFirstLine(line.toString());
+ first = false;
+ }
+ else
+ {
+ dataLength = Math.max(parseLine(line.toString()),dataLength);
+ }
+ line.reset();
+ }
+ else if(!inHeaders)
+ {
+ readLength++;
+ }
}
+ return clientRequest.toByteArray();
+ }
- /*
- * HTTP COMMAND LINE < <METHOD==get> <URL> <HTTP_VERSION> >
- */
+ public void parseFirstLine(String firstLine)
+ {
+ StringTokenizer tz = new StringTokenizer(firstLine);
method = getToken(tz).toUpperCase();
url = getToken(tz);
version = getToken(tz);
+ }
- while(true)
+ public int parseLine(String nextLine)
+ {
+ StringTokenizer tz;
+ tz = new StringTokenizer(nextLine);
+ String token = getToken(tz);
+ // look for termination of HTTP command
+ if(0 == token.length())
{
- String nextLine = null;
- try
- {
- nextLine = lines.readLine();
- tz = new StringTokenizer(nextLine);
- }
- catch(Exception e)
- {
- return false;
- }
- String Token = getToken(tz);
-
- // look for termination of HTTP command
- if(0 == Token.length())
- {
- try
- {
- if(method.equals("POST"))
- {
- postData = readPostData(lines);
- }
-
- }
- catch(Exception e)
- {
- break;
- }
- break;
- }
- else
+ return 0;
+ }
+ else
+ {
+ String name = token.trim().substring(0,token.trim().length()-1);
+ String value = getRemainder(tz);
+ headers.put(name,value);
+ if(name.equalsIgnoreCase("content-length"))
{
- if(!Token.trim().equalsIgnoreCase("host:") && !Token.trim().equalsIgnoreCase("referer:") &&
- !Token.trim().equalsIgnoreCase("proxy-connection:"))
- {
- headers.put(Token.trim().substring(0,Token.trim().length()-1),getRemainder(tz));
- }
+ return Integer.parseInt(value);
}
}
- return true;
+ return 0;
}
- public HTTPSampler getSampler(UrlConfig config) throws MalformedURLException,IOException,ProtocolException
+ public HTTPSampler getSampler() throws MalformedURLException,IOException,ProtocolException
{
HttpTestSampleGui tempGui = new HttpTestSampleGui();
- tempGui.configure(config);
+ tempGui.configure(createUrlConfig());
return (HTTPSampler)tempGui.createTestElement();
}
@@ -144,9 +144,9 @@
return (String)headers.get("Content-Type");
}
- private UrlConfig createUrlConfig(UrlConfig urlConfig)
+ private UrlConfig createUrlConfig()
{
- urlConfig = UrlConfig.createConfig(getContentType());
+ UrlConfig urlConfig = UrlConfig.createConfig(getContentType());
urlConfig.setDomain(serverName());
urlConfig.setMethod(method);
urlConfig.setPath(serverUrl());
1.3 +27 -22 jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/proxy/Proxy.java
Index: Proxy.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/protocol/http/proxy/Proxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Proxy.java 19 Apr 2002 02:08:49 -0000 1.2
+++ Proxy.java 24 Apr 2002 16:11:13 -0000 1.3
@@ -137,9 +137,7 @@
{
String serverName = "";
HttpURLConnection url;
-
byte line[];
-
HttpRequestHdr request = new HttpRequestHdr();
HttpReplyHdr reply = new HttpReplyHdr();
FileInputStream fileInputStream = null;
@@ -148,23 +146,18 @@
boolean isCachable = false;
try
{
- request.parse(new BufferedInputStream(ClientSocket.getInputStream()));
- HTTPSampler sampler = request.getSampler(urlConfig);
- sampler.addTestElement(cookieManager);
- writeFromInToOut(new BufferedInputStream(new ByteArrayInputStream(sampleServer(sampler))),
+ byte[] clientRequest = request.parse(new BufferedInputStream(ClientSocket.getInputStream()));
+ HTTPSampler sampler = request.getSampler();
+ writeToClient(sampler.getDomain(),sampler.getPort(),new BufferedInputStream(
+ new ByteArrayInputStream(clientRequest)),
new BufferedOutputStream(ClientSocket.getOutputStream()));
target.deliverSampler(sampler);
}
catch (UnknownHostException uhe)
{
- //
- // Requested Server could not be located
- //
System.out.println("Server Not Found.");
-
try
{
- // Notify client that server not found
DataOutputStream out =
new DataOutputStream(ClientSocket.getOutputStream());
out.writeBytes(reply.formServerNotFound());
@@ -174,9 +167,9 @@
{
}
}
-
catch (Exception e)
{
+ e.printStackTrace();
try
{
if (TakenFromCache)
@@ -187,19 +180,15 @@
{
fileOutputStream.close();
}
-
- // Notify client that internal error accured in proxy
DataOutputStream out =
new DataOutputStream(ClientSocket.getOutputStream());
out.writeBytes(reply.formTimeout());
out.flush();
-
}
catch (Exception uhe2)
{
}
}
-
finally
{
try
@@ -296,26 +285,42 @@
}
}
- private void writeFromInToOut(InputStream in,OutputStream out) throws IOException
+ private void writeToClient(String server,int serverPort,InputStream in,OutputStream out) throws IOException
{
- byte[] buf = new byte[4096];
- int x = 0;
+ BufferedInputStream serverIn = null;
+ BufferedOutputStream serverOut = null;
try
{
- while((x = in.read(buf)) != -1)
+ int x = 0;
+ Socket toServer = new Socket(server,serverPort);
+ serverOut = new BufferedOutputStream(toServer.getOutputStream());
+ serverIn = new BufferedInputStream(toServer.getInputStream());
+ while((x = in.read()) != -1)
{
- out.write(buf,0,x);
+ serverOut.write(x);
}
+ serverOut.flush();
+ while((x = serverIn.read()) != -1)
+ {
+ out.write(x);
+ }
+ out.flush();
+ }
+ catch(IOException e)
+ {
+ e.printStackTrace();
}
finally
{
try
{
in.close();
+ out.close();
+ serverIn.close();
+ serverOut.close();
}
catch (Exception ex)
{}
- out.flush();
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>