Author: fschumacher
Date: Sat Sep 24 12:44:48 2016
New Revision: 1762120

URL: http://svn.apache.org/viewvc?rev=1762120&view=rev
Log:
Add shortened version of the PUT body to sampler result.

Bugzilla Id: 60092

Modified:
    jmeter/trunk/bin/jmeter.properties
    
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/xdocs/usermanual/properties_reference.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1762120&r1=1762119&r2=1762120&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sat Sep 24 12:44:48 2016
@@ -480,6 +480,9 @@ log_level.jorphan=INFO
 # No matter what, the connection will not be re-used beyond its TTL. 
 #httpclient4.time_to_live=2000
 
+# Max size in bytes of PUT body to retain in result sampler. Bigger results 
will be clipped.
+#httpclient4.max_body_retain_size=32768
+
 #---------------------------------------------------------------------------
 # Apache HttpComponents Commons HTTPClient configuration (HTTPClient 3.1)
 #                            DEPRECATED

Modified: 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1762120&r1=1762119&r2=1762120&view=diff
==============================================================================
--- 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
 (original)
+++ 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
 Sat Sep 24 12:44:48 2016
@@ -39,6 +39,8 @@ import java.util.regex.Pattern;
 
 import javax.security.auth.Subject;
 
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.BoundedInputStream;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.Header;
 import org.apache.http.HttpConnection;
@@ -137,6 +139,8 @@ import org.apache.log.Logger;
  */
 public class HTTPHC4Impl extends HTTPHCAbstractImpl {
 
+    private static final int MAX_BODY_RETAIN_SIZE = 
JMeterUtils.getPropDefault("httpclient4.max_body_retain_size", 32 * 1024);
+
     private static final Logger log = LoggingManager.getLoggerForClass();
 
     /** retry count to be used (default 0); 0 = disable retries */
@@ -1441,7 +1445,11 @@ public class HTTPHC4Impl extends HTTPHCA
             // our own stream, so we can return it
             final HttpEntity entityEntry = entity.getEntity();
             if(entityEntry.isRepeatable()) {
-                entityBody.append("<actual file content, not shown here>");
+                entityBody.append(IOUtils.toString(new BoundedInputStream(
+                        entityEntry.getContent(), MAX_BODY_RETAIN_SIZE)));
+                if (entityEntry.getContentLength() > MAX_BODY_RETAIN_SIZE) {
+                    entityBody.append("<actual file content shortened>");
+                }
             }
             else { // this probably cannot happen
                 entityBody.append("<RequestEntity was not repeatable, cannot 
view what was sent>");

Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1762120&r1=1762119&r2=1762120&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Sat Sep 24 12:44:48 
2016
@@ -333,6 +333,7 @@ log_level.org.apache.http.client=DEBUG
 <property name="httpclient4.idletimeout">Idle connection timeout 
(Milliseconds) to apply if the server does not send Keep-Alive headers, 
defaults to:0 (no suggested duration for Keep-Alive))</property>
 <property name="httpclient4.validate_after_inactivity">Check connections if 
the elapsed time (Milliseconds) since the last use of the connection exceeds 
this value<br/>, defaults to:2000</property>
 <property name="httpclient4.time_to_live"> TTL (in Milliseconds) represents an 
absolute value. No matter what, the connection will not be re-used beyond its 
TTL. <br/>, defaults to:2000</property>
+<property name="httpclient4.max_body_retain_size">Max size in bytes of PUT 
body to retain in result sampler. Bigger results will be clipped.<br/>, 
defaults to: 327678 (bytes)</property>
 </properties>
 </section>
 <section name="&sect-num;.16 Apache HttpComponents Commons HTTPClient 
configuration (HTTPClient 3.1)" anchor="httpclient31">


Reply via email to