jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1839882 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Date Sun, 02 Sep 2018 13:24:52 GMT
Author: pmouawad
Date: Sun Sep  2 13:24:52 2018
New Revision: 1839882

URL: http://svn.apache.org/viewvc?rev=1839882&view=rev
Log:
Bug 62321 - Computing of response size is incorrect in nightly build
Bugzilla Id: 62321

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

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=1839882&r1=1839881&r2=1839882&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
Sun Sep  2 13:24:52 2018
@@ -182,10 +182,8 @@ public class HTTPHC4Impl extends HTTPHCA
     private static final String CONTEXT_ATTRIBUTE_CLIENT_KEY = "__jmeter.C_K__";
 
     private static final String CONTEXT_ATTRIBUTE_SENT_BYTES = "__jmeter.S_B__";
-    
-    private static final String CONTEXT_ATTRIBUTE_RECEIVED_BYTES = "__jmeter.R_B__";
-
-    private static final int MAX_BODY_RETAIN_SIZE = JMeterUtils.getPropDefault("httpclient4.max_body_retain_size",
32 * 1024);
+        
+    private static final String CONTEXT_ATTRIBUTE_METRICS = "__jmeter.M__";
 
     private static final boolean DEFLATE_RELAX_MODE = JMeterUtils.getPropDefault("httpclient4.deflate_relax_mode",
false);
 
@@ -378,6 +376,7 @@ public class HTTPHC4Impl extends HTTPHCA
     
     private static final HttpRequestInterceptor PREEMPTIVE_AUTH_INTERCEPTOR = new PreemptiveAuthRequestInterceptor();
 
+
     // see  https://stackoverflow.com/questions/26166469/measure-bandwidth-usage-with-apache-httpcomponents-httpclient
     private static final HttpRequestExecutor REQUEST_EXECUTOR = new HttpRequestExecutor()
{
 
@@ -389,26 +388,13 @@ public class HTTPHC4Impl extends HTTPHCA
             HttpResponse response = super.doSendRequest(request, conn, context);
             HttpConnectionMetrics metrics = conn.getMetrics();
             long sentBytesCount = metrics.getSentBytesCount();
+            // We save to store sent bytes as we need to reset metrics for received bytes
             context.setAttribute(CONTEXT_ATTRIBUTE_SENT_BYTES, metrics.getSentBytesCount());
+            context.setAttribute(CONTEXT_ATTRIBUTE_METRICS, metrics);
             log.debug("Sent {} bytes", sentBytesCount);
             metrics.reset();
             return response;
         }
-
-        @Override
-        protected HttpResponse doReceiveResponse(
-                final HttpRequest request,
-                final HttpClientConnection conn,
-                final HttpContext context) throws HttpException, IOException {
-            HttpResponse response = super.doReceiveResponse(request, conn, context);
-            HttpConnectionMetrics metrics = conn.getMetrics();
-            long receivedBytesCount = metrics.getReceivedBytesCount();
-            context.setAttribute(CONTEXT_ATTRIBUTE_RECEIVED_BYTES, 
-                    metrics.getReceivedBytesCount());
-            log.debug("Received {} bytes", receivedBytesCount);
-            metrics.reset();
-            return response;
-        }
     };
     
     /**
@@ -628,7 +614,8 @@ public class HTTPHC4Impl extends HTTPHCA
               + (long) httpResponse.getAllHeaders().length // Add \r for each header
               + 1L // Add \r for initial header
               + 2L; // final \r\n before data
-            long totalBytes = (Long) localContext.getAttribute(CONTEXT_ATTRIBUTE_RECEIVED_BYTES);
+            HttpConnectionMetrics metrics = (HttpConnectionMetrics) localContext.getAttribute(CONTEXT_ATTRIBUTE_METRICS);
+            long totalBytes = metrics.getReceivedBytesCount();
             res.setHeadersSize((int)headerBytes);
             res.setBodySize(totalBytes - headerBytes);
             res.setSentBytes((Long) localContext.getAttribute(CONTEXT_ATTRIBUTE_SENT_BYTES));



Mime
View raw message