Hello ,

In current Live version of JMeter we use this way of computing size of
responses for each request:

   -
   
https://github.com/apache/jmeter/blob/v4_0/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888


As we migrated to last APIs we based implementation on this SO response
from Oleg:

   -
   
https://stackoverflow.com/questions/26166469/measure-bandwidth-usage-with-apache-httpcomponents-httpclient

And ended up with this:

   -
   
https://github.com/apache/jmeter/blob/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L382

But it appears that computation is wrong and we would need to do this to be
correct:

        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();
            HttpEntity entity = response.getEntity();
            context.setAttribute(CONTEXT_ATTRIBUTE_RECEIVED_BYTES,
                    metrics.getReceivedBytesCount()+
                    (entity != null ? entity.getContentLength(): 0L));
            metrics.reset();
            return response;
        }


Is my understanding correct ? or am I missing something ?

Thanks

Regards

Reply via email to