You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2006/05/21 12:58:56 UTC
svn commit: r408156 -
/jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
Author: olegk
Date: Sun May 21 03:58:55 2006
New Revision: 408156
URL: http://svn.apache.org/viewvc?rev=408156&view=rev
Log:
Print out response body if the debug level is 4
Modified:
jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
Modified: jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java?rev=408156&r1=408155&r2=408156&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java (original)
+++ jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java Sun May 21 03:58:55 2006
@@ -39,7 +39,9 @@
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpRequestExecutor;
+import org.apache.http.util.EntityUtils;
/**
* <p>
@@ -95,6 +97,10 @@
System.out.println();
}
HttpEntity entity = response.getEntity();
+ String charset = EntityUtils.getContentCharSet(entity);
+ if (charset == null) {
+ charset = HTTP.DEFAULT_CONTENT_CHARSET;
+ }
long contentlen = 0;
if (entity != null) {
InputStream instream = entity.getContent();
@@ -102,7 +108,15 @@
while ((l = instream.read(this.buffer)) != -1) {
stats.incTotal(l);
contentlen += l;
+ if (this.verbosity >= 4) {
+ String s = new String(this.buffer, 0, l, charset);
+ System.out.print(s);
+ }
}
+ }
+ if (this.verbosity >= 4) {
+ System.out.println();
+ System.out.println();
}
if (!keepalive || !this.connstrategy.keepAlive(response)) {
conn.close();