hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r408156 - /jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/BenchmarkWorker.java
Date Sun, 21 May 2006 10:58:56 GMT
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();



Mime
View raw message