jakarta-jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wool...@apache.org
Subject svn commit: r432792 - in /jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy: Proxy.java ProxyControl.java gui/ProxyControlGui.java
Date Sat, 19 Aug 2006 04:10:35 GMT
Author: woolfel
Date: Fri Aug 18 21:10:33 2006
New Revision: 432792

URL: http://svn.apache.org/viewvc?rev=432792&view=rev
Log:
applying the https contribution from Carl Nygaard <cnygaard@google.com>

Modified:
    jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
    jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
    jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java

Modified: jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java?rev=432792&r1=432791&r2=432792&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
(original)
+++ jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
Fri Aug 18 21:10:33 2006
@@ -57,6 +57,9 @@
 	/** Whether or not to capture the HTTP headers. */
 	private boolean captureHttpHeaders;
 
+	/** Whether to try to spoof as https **/
+	private boolean httpsSpoof;
+
 	/**
 	 * Default constructor - used by newInstance call in Daemon
 	 */
@@ -87,6 +90,7 @@
 		this.target = _target;
 		this.clientSocket = _clientSocket;
 		this.captureHttpHeaders = _target.getCaptureHttpHeaders();
+		this.httpsSpoof = target.getHttpsSpoof();
 	}
 
 	/**
@@ -109,7 +113,25 @@
 			 */
 			headers = request.getHeaderManager();
 			sampler.setHeaderManager(headers);
+			
+			/* 
+			 * If we are trying to spoof https, change the protocol
+			 */
+			if (httpsSpoof) {
+				sampler.setProtocol("https");
+			}
 			result = sampler.sample();
+			
+			/*
+			 * If we're dealing with text data, and if we're spoofing https, 
+			 * replace all occurences of "https" with "http" for the client. 
+			 */
+			if (httpsSpoof && result.getDataType() == result.TEXT)
+			{
+				String noHttpsResult = new String(result.getResponseData());
+				result.setResponseData(noHttpsResult.replaceAll("https", "http").getBytes());
+			}
+				
 			writeToClient(result, new BufferedOutputStream(clientSocket.getOutputStream()));
 			/*
 			 * We don't want to store any cookies in the generated test plan

Modified: jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java?rev=432792&r1=432791&r2=432792&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
(original)
+++ jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/ProxyControl.java
Fri Aug 18 21:10:33 2006
@@ -115,6 +115,8 @@
 
 	public static final String REGEX_MATCH = "ProxyControlGui.regex_match"; // $NON-NLS-1$
 
+	public static final String HTTPS_SPOOF = "ProxyControlGui.https_spoof";
+
 	public static final int GROUPING_NO_GROUPS = 0;
 
 	public static final int GROUPING_ADD_SEPARATORS = 1;
@@ -136,7 +138,7 @@
 	private boolean useKeepAlive;
 
 	private boolean regexMatch = false;// Should we match using regexes?
-
+	
 	/**
 	 * Tree node where the samples should be stored.
 	 * <p>
@@ -197,7 +199,14 @@
 		regexMatch = b;
 		setProperty(new BooleanProperty(REGEX_MATCH, b));
 	}
-
+	
+	/**
+	 * @param b
+	 */
+	public void setHttpsSpoof(boolean b) {
+		setProperty(new BooleanProperty(HTTPS_SPOOF, b));
+	}
+	
 	public String getClassLabel() {
 		return JMeterUtils.getResString("proxy_title");
 	}
@@ -233,6 +242,12 @@
 	public boolean getRegexMatch() {
 		return getPropertyAsBoolean(REGEX_MATCH, false);
 	}
+	
+	public boolean getHttpsSpoof() {
+		return getPropertyAsBoolean(HTTPS_SPOOF, false);
+	}
+	
+	
 
 	public Class getGuiClass() {
 		return org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui.class;

Modified: jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java?rev=432792&r1=432791&r2=432792&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
(original)
+++ jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java
Fri Aug 18 21:10:33 2006
@@ -103,6 +103,12 @@
 	 */
 	private JCheckBox regexMatch;
 
+	/*
+	 * Spoof the client into thinking that it is communicating with http
+	 * even if it is really https.
+	 */
+	private JCheckBox httpsSpoof;
+	
 	/**
 	 * List of available target controllers
 	 */
@@ -177,6 +183,7 @@
 			model.setAssertions(addAssertions.isSelected());
 			model.setUseKeepAlive(useKeepAlive.isSelected());
 			model.setRegexMatch(regexMatch.isSelected());
+			model.setHttpsSpoof(httpsSpoof.isSelected());			
 			TreeNodeWrapper nw = (TreeNodeWrapper) targetNodes.getSelectedItem();
 			if (nw == null) {
 				model.setTarget(null);
@@ -223,6 +230,7 @@
 		addAssertions.setSelected(model.getAssertions());
 		useKeepAlive.setSelected(model.getUseKeepalive());
 		regexMatch.setSelected(model.getRegexMatch());
+		httpsSpoof.setSelected(model.getHttpsSpoof());
 
 		reinitializeTargetCombo();// Set up list of potential targets and
 									// enable listener
@@ -282,7 +290,8 @@
 			model.stopProxy();
 			startProxy();
 		} else if (command.equals(ProxyControl.CAPTURE_HTTP_HEADERS) || command.equals(ProxyControl.ADD_ASSERTIONS)
-				|| command.equals(ProxyControl.USE_KEEPALIVE) || command.equals(ProxyControl.REGEX_MATCH))
{
+				|| command.equals(ProxyControl.USE_KEEPALIVE) || command.equals(ProxyControl.REGEX_MATCH)
+				|| command.equals(ProxyControl.HTTPS_SPOOF)) {
 			enableRestart();
 		} else if (command.equals(ADD_EXCLUDE)) {
 			excludeModel.addNewRow();
@@ -462,6 +471,12 @@
 		regexMatch.addActionListener(this);
 		regexMatch.setActionCommand(ProxyControl.REGEX_MATCH);
 
+		httpsSpoof = new JCheckBox(JMeterUtils.getResString("proxy_httpsspoofing"));
+		httpsSpoof.setName(ProxyControl.HTTPS_SPOOF);
+		httpsSpoof.setSelected(false);
+		httpsSpoof.addActionListener(this);
+		httpsSpoof.setActionCommand(ProxyControl.HTTPS_SPOOF);		
+		
 		HorizontalPanel panel = new HorizontalPanel();
 		panel.add(label);
 		panel.add(portField);
@@ -472,6 +487,7 @@
 		panel.add(useKeepAlive);
 		panel.add(addAssertions);
 		panel.add(regexMatch);
+		panel.add(httpsSpoof);
 
 		return panel;
 	}



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org


Mime
View raw message