You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2012/10/14 15:52:00 UTC
svn commit: r1398084 - in /jmeter/trunk:
src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
xdocs/changes.xml xdocs/usermanual/component_reference.xml
Author: pmouawad
Date: Sun Oct 14 13:52:00 2012
New Revision: 1398084
URL: http://svn.apache.org/viewvc?rev=1398084&view=rev
Log:
Bug 54005 - HTTP Mirror Server : Add special headers "X-" to control Response status and response content
Bugzilla Id: 54005
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HttpMirrorThread.java
jmeter/trunk/xdocs/changes.xml
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=1398084&r1=1398083&r2=1398084&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 Oct 14 13:52:00 2012
@@ -85,13 +85,27 @@ public class HttpMirrorThread implements
baos.close();
final String headerString = headers.toString();
+ // Look for special Response Length header
+ String responseStatusValue = getRequestHeaderValue(headerString, "X-ResponseStatus"); //$NON-NLS-1$
+ if(responseStatusValue == null) {
+ responseStatusValue = "200 OK";
+ }
+
log.debug("Write headers");
out = new BufferedOutputStream(clientSocket.getOutputStream());
// The headers are written using ISO_8859_1 encoding
- out.write("HTTP/1.0 200 OK".getBytes(ISO_8859_1)); //$NON-NLS-1$
+ out.write(("HTTP/1.0 "+responseStatusValue).getBytes(ISO_8859_1)); //$NON-NLS-1$
out.write(CRLF);
out.write("Content-Type: text/plain".getBytes(ISO_8859_1)); //$NON-NLS-1$
out.write(CRLF);
+
+ // Look for special Response Length header
+ String responseLengthValue = getRequestHeaderValue(headerString, "X-ResponseLength"); //$NON-NLS-1$
+ int responseLength=-1;
+ if(responseLengthValue != null) {
+ responseLength = Integer.parseInt(responseLengthValue);
+ }
+
// Look for special Cookie request
String cookieHeaderValue = getRequestHeaderValue(headerString, "X-SetCookie"); //$NON-NLS-1$
if (cookieHeaderValue != null) {
@@ -102,8 +116,11 @@ public class HttpMirrorThread implements
out.write(CRLF);
out.flush();
- out.write(baos.toByteArray());
-
+ if(responseLength>=0) {
+ out.write(baos.toByteArray(), 0, Math.min(baos.toByteArray().length, responseLength));
+ } else {
+ out.write(baos.toByteArray());
+ }
// Check if we have found a content-length header
String contentLengthHeaderValue = getRequestHeaderValue(headerString, "Content-Length"); //$NON-NLS-1$
if(contentLengthHeaderValue != null) {
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1398084&r1=1398083&r2=1398084&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Oct 14 13:52:00 2012
@@ -154,6 +154,7 @@ and right angle bracket (>) in search
<h3>General</h3>
<ul>
+<li><bugzilla>54005</bugzilla> - HTTP Mirror Server : Add special headers "X-" to control Response status and response content</li>
</ul>
<h2>Non-functional changes</h2>
Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1398084&r1=1398083&r2=1398084&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sun Oct 14 13:52:00 2012
@@ -5514,10 +5514,14 @@ 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 make simulate requests response time by adding an HTTP Header Manager with the following name/value pair:
-<ul>
-<li>X-Sleep=Time to sleep in ms </li>
-</ul>
+Note that you can get more control on responses by adding an HTTP Header Manager with the following name/value pairs:
+<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 Stauts 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>
+</properties>
+
</note>
</component>