Author: sebb
Date: Sat Nov 17 09:40:11 2007
New Revision: 595978

URL: http://svn.apache.org/viewvc?rev=595978&view=rev
Log:
Proxy spoofing now drops the default HTTPS port (443) when converting https: 
links to http:
Update Proxy documentation

Modified:
    jakarta/jmeter/trunk/docs/images/screenshots/proxy_control.png
    
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/images/screenshots/proxy_control.png
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jakarta/jmeter/trunk/docs/images/screenshots/proxy_control.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/docs/images/screenshots/proxy_control.png?rev=595978&r1=595977&r2=595978&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java?rev=595978&r1=595977&r2=595978&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/Proxy.java
 Sat Nov 17 09:40:11 2007
@@ -28,7 +28,6 @@
 import java.net.URL;
 import java.util.Map;
 
-import org.apache.commons.httpclient.HttpConstants;
 import org.apache.jmeter.protocol.http.control.HeaderManager;
 import org.apache.jmeter.protocol.http.parser.HTMLParseException;
 import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
@@ -175,14 +174,17 @@
                        /* 
                         * If we are trying to spoof https, change the protocol
                         */
+                       boolean forcedHTTP = false; // so we know when to revert
                        if (httpsSpoof) {
                                if (httpsSpoofMatch.length() > 0){
                                        String url = request.getUrl();
                                        if (url.matches(httpsSpoofMatch)){
-                                               
sampler.setProtocol(HTTPConstants.PROTOCOL_HTTPS);                              
                
+                                               
sampler.setProtocol(HTTPConstants.PROTOCOL_HTTPS);
+                                               forcedHTTP = true;
                                        }
                                } else {
                                    
sampler.setProtocol(HTTPConstants.PROTOCOL_HTTPS);
+                                       forcedHTTP = true;
                                }
                        }
                        sampler.threadStarted(); // Needed for HTTPSampler2
@@ -190,12 +192,17 @@
                        
                        /*
                         * If we're dealing with text data, and if we're 
spoofing https, 
-                        * replace all occurences of "https:" with "http:" for 
the client. 
+                        * replace all occurences of "https://"; with "http://"; 
for the client.
+                        * TODO - also check the match string to restrict the 
changes further?
                         */
-                       if (httpsSpoof && 
SampleResult.TEXT.equals(result.getDataType()))
+                       if (forcedHTTP && 
SampleResult.TEXT.equals(result.getDataType()))
                        {
-                               String noHttpsResult = new 
String(result.getResponseData());
-                               
result.setResponseData(noHttpsResult.replaceAll("https:", 
"http:").getBytes());// TODO this could mangle the encoding
+                               final String enc = 
result.getDataEncodingWithDefault();
+                               String noHttpsResult = new 
String(result.getResponseData(),enc);
+                               final String HTTPS_HOST = // match 
https://host[:port]/ and drop default port if present
+                                       
"https://([^:/]+)(:"+HTTPConstants.DEFAULT_HTTPS_PORT_STRING+")?"; // 
$NON-NLS-1$ $NON-NLS-2$
+                               noHttpsResult = 
noHttpsResult.replaceAll(HTTPS_HOST, "http://$1";); // $NON-NLS-1$
+                               
result.setResponseData(noHttpsResult.getBytes(enc));
                        }
 
             // Find the page encoding and possibly encodings for forms in the 
page

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=595978&r1=595977&r2=595978&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sat Nov 17 09:40:11 2007
@@ -107,6 +107,7 @@
 <li>Ensure ResultCollector uses SaveService encoding</li>
 <li>Proxy now rejects attempts to use it with https</li>
 <li>Proxy spoofing can now use RE matching to determine which urls to spoof 
(useful if images are not https)</li>
+<li>Proxy spoofing now drops the default HTTPS port (443) when converting 
https: links to http:</li>
 </ul>
 
 <h4>Non-functional Improvements</h4>

Modified: jakarta/jmeter/trunk/xdocs/images/screenshots/proxy_control.png
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/images/screenshots/proxy_control.png?rev=595978&r1=595977&r2=595978&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=595978&r1=595977&r2=595978&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Sat Nov 17 
09:40:11 2007
@@ -3371,32 +3371,43 @@
 </p>
 </component>
 
-<component name="HTTP Proxy Server" index="&sect-num;.9.5"  width="960" 
height="650" screenshot="proxy_control.png">
+<component name="HTTP Proxy Server" index="&sect-num;.9.5"  width="951" 
height="611" screenshot="proxy_control.png">
 <note>The Proxy Server can only record HTTP traffic. 
 It is not possible to record HTTPS (SSL) sessions; however there is an HTTPS 
spoofing mode - see below.</note>
 <description><p>The Proxy Server allows JMeter to watch and record your 
actions while you browse your web application
-with your normal browser (such as Internet Explorer).  JMeter will create test 
sample objects and store them
+with your normal browser.  JMeter will create test sample objects and store 
them
 directly into your test plan as you go (so you can view samples interactively 
while you make them).</p>
 
 <p>To use the proxy server, <i>add</i> the HTTP Proxy Server element to the 
workbench.
 Select the WorkBench element in the tree, and right-click on this element to 
get the
 Add menu (Add --> Non-Test Elements --> HTTP Proxy Server).</p>
+<p>
+You also need to set up your browser to use the JMeter proxy port as the proxy 
for HTTP requests.
+Do not use JMeter as the proxy for any other request types - HTTPS, FTP, etc. 
- as the JMeter proxy cannot handle them.
+</p>
 </description>
 
 <properties>
         <property name="Name" required="No">Descriptive name for this 
controller that is shown in the tree.</property>
         <property name="Port" required="Yes">The port that the Proxy Server 
listens to.  8080 is the default, but you can change it.</property>
-        <property name="Attempt https Spoofing" required="Yes">
-          When you enable https spoofing, the following  happens:
+        <property name="Attempt HTTPS Spoofing" required="Yes">
+          When you enable HTTPS spoofing, the following  happens:
           <ul>
-            <li>All http requests from the client are turned into https 
(between the proxy
+            <li>All matching (see below) http requests from the client are 
turned into https (between the proxy
               and the web server).</li>
-            <li>All text response data is scanned and any occurrence of the 
string "https" 
-              is replaced with &quot;http.&quot;</li>
+            <li>All text response data is scanned and any occurrence of the 
string "https://"; 
+              is replaced with "http://";; the default HTTPS port (443) is also 
removed if present.</li>
           </ul>
           So if you want to use this feature, while you are browsing in your 
client,
-          instead of typing "https://..."; into the browser, type 
&quot;http://...&quot;.  JMeter
-          will request and record <i>everything</i> as https, whether it 
should be or not.
+          instead of typing "https://..."; into the browser, type "http://...";. 
 
+          JMeter will request and record <i>everything that matches</i> as 
https, whether it should be or not.
+        </property>
+        <property name="Optional URL match string" required="No">
+        If this is specified, it must be a regular expression 
(java.util.regex) which matches the
+        HTTP URL(s) to be spoofed.
+        For example, if you want to spoof http://a.b.c/service/ but not 
http://a.b.c/images,
+        then you could use the expression "http://a.b.c/service/.*";.
+        Note that the expression ends in ".*" because it must match the whole 
URL.
         </property>
         <property name="Target Controller" required="Yes">The controller where 
the proxy will store the generated samples. By default, it will look for a 
Recording Controller and store them there wherever it is.</property>
         <property name="Grouping" required="Yes">Whether to group samplers for 
requests from a single "click" (requests received without significant time 
separation), and how to represent that grouping in the recording:



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to