Add shortened version of the PUT body to sampler result.

Bugzilla Id: 60092


git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1762120 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: 3b0162c77c
This commit is contained in:
Felix Schumacher 2016-09-24 12:44:48 +00:00
parent d486459752
commit 660c5d34a8
3 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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 HTTPHCAbstractImpl {
// 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>");

View File

@ -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">