You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2014/03/16 15:52:21 UTC

svn commit: r1578094 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java xdocs/usermanual/component_reference.xml

Author: sebb
Date: Sun Mar 16 14:52:21 2014
New Revision: 1578094

URL: http://svn.apache.org/r1578094
Log:
Document new Mirror query features; add verbose flag

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java?rev=1578094&r1=1578093&r2=1578094&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java Sun Mar 16 14:52:21 2014
@@ -52,6 +52,7 @@ import org.apache.oro.text.regex.Perl5Ma
  * It also responds to some query strings:
  * status=nnn Message (overrides X-ResponseStatus)
  * redirect=location - sends a temporary redirect
+ * v - verbose, i.e. print some details to stdout
  */
 public class HttpMirrorThread implements Runnable {
     private static final Logger log = LoggingManager.getLoggerForClass();
@@ -63,6 +64,8 @@ public class HttpMirrorThread implements
 
     private static final String STATUS = "status"; //$NON-NLS-1$
 
+    private static final String VERBOSE = "v"; // $NON-NLS-1$
+
     /** Socket to client. */
     private final Socket clientSocket;
 
@@ -104,7 +107,8 @@ public class HttpMirrorThread implements
 
             baos.close();
             final String headerString = headers.toString();
-            final String[] requestParts = headerString.split("\\s+",3);
+            final String firstLine = headerString.substring(0, headerString.indexOf('\r'));
+            final String[] requestParts = firstLine.split("\\s+");
             final String requestMethod = requestParts[0];
             final String requestPath = requestParts[1];
             final HashMap<String, String> parameters = new HashMap<String, String>();
@@ -125,12 +129,20 @@ public class HttpMirrorThread implements
                             String parts[] = param.split("=",2);
                             if (parts.length==2) {
                                 parameters.put(parts[0], parts[1]);
+                            } else { // allow for parameter name only
+                                parameters.put(parts[0], "");
                             }
                         }
                     }
                 }
             }
 
+            final boolean verbose = parameters.containsKey(VERBOSE);
+            
+            if (verbose) {
+                System.out.println(firstLine);
+            }
+
             // Look for special Response Length header
             String responseStatusValue = getRequestHeaderValue(headerString, "X-ResponseStatus"); //$NON-NLS-1$
             if(responseStatusValue == null) {
@@ -153,8 +165,15 @@ public class HttpMirrorThread implements
             out.write(CRLF);
 
             if (parameters.containsKey(REDIRECT)) {
-                out.write((HTTPConstants.HEADER_LOCATION + ": ").getBytes(ISO_8859_1)); //$NON-NLS-1$
-                out.write(parameters.get(REDIRECT).getBytes(ISO_8859_1));
+                StringBuilder sb = new StringBuilder();
+                sb.append(HTTPConstants.HEADER_LOCATION);
+                sb.append(": "); //$NON-NLS-1$
+                sb.append(parameters.get(REDIRECT));
+                final String redirectLocation = sb.toString();
+                if (verbose) {
+                    System.out.println(redirectLocation);
+                }
+                out.write(redirectLocation.getBytes(ISO_8859_1));
                 out.write(CRLF);
             }
 

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1578094&r1=1578093&r2=1578094&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sun Mar 16 14:52:21 2014
@@ -6157,18 +6157,27 @@ It uses default port 8081 since 2.6. 
         be held in this queue and discarded when this queue is full. This parameter is only used if Max Number of Threads is greater than 0. Defaults to 25</property>
 </properties>
 <note>
-Note that you can get more control on responses by adding an HTTP Header Manager with the following name/value pairs:
+Note that you can get more control over the responses by adding an HTTP Header Manager with the following name/value pairs:
+</note>
 <properties>
         <property name="X-Sleep" required="No">Time to sleep in ms before sending response</property>
         <property name="X-SetCookie" required="No">Cookies to be set on response</property>
         <property name="X-ResponseStatus" required="No">Response status, see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP Status responses</a>, example 200 OK, 500 Internal Server Error ....</property>
-        <property name="X-ResponseLength" required="No">Size of response, this enable returning only a substring of Request content</property>
-        <property name="X-SetHeaders" required="No">Pipe separator list of headers, example:<br/> 
+        <property name="X-ResponseLength" required="No">Size of response, this trims the response to the requested size if that is less than the total size</property>
+        <property name="X-SetHeaders" required="No">Pipe separated list of headers, example:<br/> 
         <code>headerA=valueA|headerB=valueB</code> would set headerA to valueA and headerB to valueB.        
         </property>
 </properties>
-
-</note>
+<p>
+You can also use the following query parameters:
+</p>
+<properties>
+    <property name="redirect" required="No">Generates a 302 (Temporary Redirect) with the provided location.
+    e.g. ?redirect=/path 
+    </property>
+    <property name="status" required="No">Overrides the default status return. e.g. ?status=404 Not Found</property>
+    <property name="v" required="No">Verbose flag, writes some details to standard output. e.g. first line and redirect location if specified</property>
+</properties>
 </component>
 
 <component name="Property Display" index="&sect-num;.9.7"  width="804" height="508" screenshot="property_display.png">