Author: sebb
Date: Wed Apr 20 00:22:12 2011
New Revision: 1095243

URL: http://svn.apache.org/viewvc?rev=1095243&view=rev
Log:
Cannot rely on initial call to getReceivedBytesCount being the same as the 
header byte count - it can be larger if the socket returns a larger chunk - so 
calculate header size from the response headers.

Modified:
    
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java

Modified: 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1095243&r1=1095242&r2=1095243&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
 (original)
+++ 
jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
 Wed Apr 20 00:22:12 2011
@@ -266,14 +266,6 @@ public class HTTPHC4Impl extends HTTPHCA
             // Needs to be done after execute to pick up all the headers
             res.setRequestHeaders(getConnectionHeaders((HttpRequest) 
localContext.getAttribute(ExecutionContext.HTTP_REQUEST)));
 
-            // Fetch the metrics now, so we can get the header count
-            
-//            HttpConnection conn = (HttpConnection) 
localContext.getAttribute(ExecutionContext.HTTP_REQUEST); // this works
-//            HttpConnectionMetrics metrics = conn.getMetrics(); // this fails 
on http core 4.1 with a HEAD request
-            // alternate hack to be removed when httpcore fixed
-            HttpConnectionMetrics  metrics = (HttpConnectionMetrics) 
localContext.getAttribute(CONTEXT_METRICS);
-            long headerBytes = metrics.getReceivedBytesCount();
-
             HttpEntity entity = httpResponse.getEntity();
             if (entity != null) {
                 InputStream instream = entity.getContent();
@@ -306,6 +298,12 @@ public class HTTPHC4Impl extends HTTPHCA
             }
 
             // record some sizes to allow HTTPSampleResult.getBytes() with 
different options
+            HttpConnectionMetrics  metrics = (HttpConnectionMetrics) 
localContext.getAttribute(CONTEXT_METRICS);
+            long headerBytes = 
+                res.getResponseHeaders().length()   // condensed length 
(without \r)
+              + httpResponse.getAllHeaders().length // Add \r for each header
+              + 1 // Add \r for initial header
+              + 2; // final \r\n before data
             long totalBytes = metrics.getReceivedBytesCount();
             res.setHeadersSize((int) headerBytes);
             res.setBodySize((int)(totalBytes - headerBytes));



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@jakarta.apache.org
For additional commands, e-mail: notifications-h...@jakarta.apache.org

Reply via email to