Discussion:
Correct way of computing Response size
Philippe Mouawad
2018-04-20 09:09:46 UTC
Permalink
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
Oleg Kalnichevski
2018-04-20 09:21:30 UTC
Permalink
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of computing size of
   -
   https://github.com/apache/jmeter/blob/v4_0/src/protocol/http/org/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on this SO
response
   -
   https://stackoverflow.com/questions/26166469/measure-bandwidth-usa
ge-with-apache-httpcomponents-httpclient
   -
   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
        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()+
0L));
            metrics.reset();
            return response;
        }
Philippe

Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?

Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Philippe Mouawad
2018-04-20 09:40:02 UTC
Permalink
Hello Oleg,
Thanks for rapid answer.
The body size including entity.

I'd like the header size to be aside, I already know how to compute header
size.

Regards
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of computing size of
-
https://github.com/apache/jmeter/blob/v4_0/src/protocol/http/org/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on this SO response
-
https://stackoverflow.com/questions/26166469/measure-bandwidth-usa
ge-with-apache-httpcomponents-httpclient
-
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
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;
}
Philippe
Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
---------------------------------------------------------------------
--
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

UBIK LOAD PACK Web Site <http://www.ubikloadpack.com/>

UBIK LOAD PACK on TWITTER <https://twitter.com/ubikloadpack>
Oleg Kalnichevski
2018-04-20 11:01:35 UTC
Permalink
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size of transfer
encoding elements) or content bytes only (same of Content-Length when
present)?

It would be much easier if you took the size of the entire message.

Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to compute header
size.
Regards
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of computing
size
of
   -
   https://github.com/apache/jmeter/blob/v4_0/src/protocol/http/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on this SO response
   -
   https://stackoverflow.com/questions/26166469/measure-bandwidth
-usa
ge-with-apache-httpcomponents-httpclient
   -
   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
        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()+
0L));
            metrics.reset();
            return response;
        }
Philippe
Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Philippe Mouawad
2018-04-20 12:31:51 UTC
Permalink
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size of transfer
encoding elements)
Can you illustrate so that I am sure to understand what you mean by size of
transfer
encoding elements ?
Post by Oleg Kalnichevski
or content bytes only (same of Content-Length when
present)?
It would be much easier if you took the size of the entire message.
How should I proceed ?
Post by Oleg Kalnichevski
Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to compute header
size.
Regards
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of computing
size
of
-
https://github.com/apache/jmeter/blob/v4_0/src/protocol/http/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on this SO response
-
https://stackoverflow.com/questions/26166469/measure-bandwidth
-usa
ge-with-apache-httpcomponents-httpclient
-
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
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;
}
Philippe
Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
--
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

UBIK LOAD PACK Web Site <http://www.ubikloadpack.com/>

UBIK LOAD PACK on TWITTER <https://twitter.com/ubikloadpack>
Oleg Kalnichevski
2018-04-20 12:58:55 UTC
Permalink
g.com>
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size of transfer
encoding elements)
Can you illustrate so that I am sure to understand what you mean by size of
transfer
encoding elements ?
---
HTTP/1.1 200 OK\r\n
Content-Length: 5\r\n
\r\n
stuff
---

total message length: 43
raw content length: 5
content length: 5

---
HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
\r\n
5\r\n
stuff0\r\n
\r\
n
---

total message length: 60
raw content length: 16
content length: 5

What number are you after?

Oleg
Post by Oleg Kalnichevski
or content bytes only (same of Content-Length when
present)?
It would be much easier if you took the size of the entire message.
How should I proceed ?
Post by Oleg Kalnichevski
Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to
compute
header
size.
Regards
.org
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of
computing
size
of
   -
   https://github.com/apache/jmeter/blob/v4_0/src/protocol/ht
tp/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on this SO
response
   -
   https://stackoverflow.com/questions/26166469/measure-bandw
idth
-usa
ge-with-apache-httpcomponents-httpclient
   -
   https://github.com/apache/jmeter/blob/trunk/src/protocol/h
ttp/
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
        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_B
YTES
,
                    metrics.getReceivedBytesCount()+
                    (entity != null ?
0L));
            metrics.reset();
            return response;
        }
Philippe
Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
-------------------------------------------------------------
----
----
org
e.or
g
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Philippe Mouawad
2018-04-20 13:01:10 UTC
Permalink
I am looking for raw content length
Post by Oleg Kalnichevski
g.com>
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size of transfer
encoding elements)
Can you illustrate so that I am sure to understand what you mean by size of
transfer
encoding elements ?
---
HTTP/1.1 200 OK\r\n
Content-Length: 5\r\n
\r\n
stuff
---
total message length: 43
raw content length: 5
content length: 5
---
HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
\r\n
5\r\n
stuff0\r\n
\r\
n
---
total message length: 60
raw content length: 16
content length: 5
What number are you after?
Oleg
Post by Oleg Kalnichevski
or content bytes only (same of Content-Length when
present)?
It would be much easier if you took the size of the entire message.
How should I proceed ?
Post by Oleg Kalnichevski
Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to
compute
header
size.
Regards
.org
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of
computing
size
of
-
https://github.com/apache/jmeter/blob/v4_0/src/protocol/ht
tp/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on this SO
response
-
https://stackoverflow.com/questions/26166469/measure-bandw
idth
-usa
ge-with-apache-httpcomponents-httpclient
-
https://github.com/apache/jmeter/blob/trunk/src/protocol/h
ttp/
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
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_B
YTES
,
metrics.getReceivedBytesCount()+
(entity != null ?
0L));
metrics.reset();
return response;
}
Philippe
Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
-------------------------------------------------------------
----
----
org
e.or
g
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
--
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

UBIK LOAD PACK Web Site <http://www.ubikloadpack.com/>

UBIK LOAD PACK on TWITTER <https://twitter.com/ubikloadpack>
Oleg Kalnichevski
2018-04-20 13:28:16 UTC
Permalink
Post by Philippe Mouawad
I am looking for raw content length
This cannot be done reliably with HttpClient 4.x (or I cannot think of
a way at the moment) as it requires a direct access to the underlying
connection. It would require dropping to HttpCore level and a manual
connection management.

Oleg
Post by Philippe Mouawad
Post by Oleg Kalnichevski
ltin
g.com>
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size of transfer
encoding elements)
Can you illustrate so that I am sure to understand what you mean
by
size of
transfer
encoding elements ?
---
HTTP/1.1 200 OK\r\n
Content-Length: 5\r\n
\r\n
stuff
---
total message length: 43
raw content length: 5
content length: 5
---
HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
\r\n
5\r\n
stuff0\r\n
\r\
n
---
total message length: 60
raw content length: 16
content length: 5
What number are you after?
Oleg
Post by Oleg Kalnichevski
or content bytes only (same of Content-Length when
present)?
It would be much easier if you took the size of the entire message.
How should I proceed ?
Post by Oleg Kalnichevski
Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to
compute
header
size.
Regards
ache
.org
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of computing
size
of
   -
   https://github.com/apache/jmeter/blob/v4_0/src/protoco
l/ht
tp/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on
this
SO
response
   -
   https://stackoverflow.com/questions/26166469/measure-b
andw
idth
-usa
ge-with-apache-httpcomponents-httpclient
   -
   https://github.com/apache/jmeter/blob/trunk/src/protoc
ol/h
ttp/
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
        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_RECEIV
ED_B
YTES
,
                    metrics.getReceivedBytesCount()+
                    (entity != null ?
0L));
            metrics.reset();
            return response;
        }
Philippe
Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
---------------------------------------------------------
----
----
----
che.
org
pach
e.or
g
-------------------------------------------------------------
----
----
org
e.or
g
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Philippe Mouawad
2018-04-20 13:29:18 UTC
Permalink
Is this approximation acceptable ?
context.setAttribute(CONTEXT_ATTRIBUTE_RECEIVED_BYTES,
metrics.getReceivedBytesCount()+
(entity != null ? entity.getContentLength(): 0L));
Post by Philippe Mouawad
I am looking for raw content length
This cannot be done reliably with HttpClient 4.x (or I cannot think of
a way at the moment) as it requires a direct access to the underlying
connection. It would require dropping to HttpCore level and a manual
connection management.
Oleg
Post by Philippe Mouawad
Post by Oleg Kalnichevski
ltin
g.com>
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size of transfer
encoding elements)
Can you illustrate so that I am sure to understand what you mean
by
size of
transfer
encoding elements ?
---
HTTP/1.1 200 OK\r\n
Content-Length: 5\r\n
\r\n
stuff
---
total message length: 43
raw content length: 5
content length: 5
---
HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
\r\n
5\r\n
stuff0\r\n
\r\
n
---
total message length: 60
raw content length: 16
content length: 5
What number are you after?
Oleg
Post by Oleg Kalnichevski
or content bytes only (same of Content-Length when
present)?
It would be much easier if you took the size of the entire message.
How should I proceed ?
Post by Oleg Kalnichevski
Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to
compute
header
size.
Regards
ache
.org
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of computing
size
of
-
https://github.com/apache/jmeter/blob/v4_0/src/protoco
l/ht
tp/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L888
As we migrated to last APIs we based implementation on
this
SO
response
-
https://stackoverflow.com/questions/26166469/measure-b
andw
idth
-usa
ge-with-apache-httpcomponents-httpclient
-
https://github.com/apache/jmeter/blob/trunk/src/protoc
ol/h
ttp/
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
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_RECEIV
ED_B
YTES
,
metrics.getReceivedBytesCount()+
(entity != null ?
0L));
metrics.reset();
return response;
}
Philippe
Are you trying to calculate the size of an entire response (message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing something ?
Thanks
Regards
---------------------------------------------------------
----
----
----
che.
org
pach
e.or
g
-------------------------------------------------------------
----
----
org
e.or
g
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
--
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

UBIK LOAD PACK Web Site <http://www.ubikloadpack.com/>

UBIK LOAD PACK on TWITTER <https://twitter.com/ubikloadpack>
Oleg Kalnichevski
2018-04-20 13:41:00 UTC
Permalink
Post by Philippe Mouawad
Is this approximation acceptable ?
context.setAttribute(CONTEXT_ATTRIBUTE_RECEIVED_BYTES,
                    metrics.getReceivedBytesCount()+
0L));
It depends what consider acceptable but this will produce complete
garbage for chunked messages as their entity content length is always
-1.

Oleg
Post by Philippe Mouawad
Post by Philippe Mouawad
I am looking for raw content length
This cannot be done reliably with HttpClient 4.x (or I cannot think of
a way at the moment) as it requires a direct access to the
underlying
connection. It would require dropping to HttpCore level and a manual
connection management.
Oleg
Post by Philippe Mouawad
org>
Post by Oleg Kalnichevski
onsu
ltin
g.com>
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size
of
transfer
encoding elements)
Can you illustrate so that I am sure to understand what you mean
by
size of
transfer
encoding elements ?
---
HTTP/1.1 200 OK\r\n
Content-Length: 5\r\n
\r\n
stuff
---
total message length: 43
raw content length: 5
content length: 5
---
HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
\r\n
5\r\n
stuff0\r\n
\r\
n
---
total message length: 60
raw content length: 16
content length: 5
What number are you after?
Oleg
Post by Oleg Kalnichevski
or content bytes only (same of Content-Length when
present)?
It would be much easier if you took the size of the entire message.
How should I proceed ?
Post by Oleg Kalnichevski
Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to
compute
header
size.
Regards
On Fri, Apr 20, 2018 at 11:21 AM, Oleg Kalnichevski <oleg
ache
.org
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of
computing
size
of
   -
   https://github.com/apache/jmeter/blob/v4_0/src/pro
toco
l/ht
tp/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L
888
As we migrated to last APIs we based implementation on
this
SO
response
   -
   https://stackoverflow.com/questions/26166469/measu
re-b
andw
idth
-usa
ge-with-apache-httpcomponents-httpclient
   -
   https://github.com/apache/jmeter/blob/trunk/src/pr
otoc
ol/h
ttp/
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
        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_RE
CEIV
ED_B
YTES
,
                    metrics.getReceivedBytesCount()+
                    (entity != null ?
0L));
            metrics.reset();
            return response;
        }
Philippe
Are you trying to calculate the size of an entire
response
(message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing
something ?
Thanks
Regards
-----------------------------------------------------
----
----
----
----
.apa
che.
org
hc.a
pach
e.or
g
---------------------------------------------------------
----
----
----
che.
org
pach
e.or
g
-------------------------------------------------------------
----
----
org
e.or
g
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-***@hc.apache.org
For additional commands, e-mail: httpclient-users-***@hc.apache.org
Philippe Mouawad
2018-04-20 15:21:17 UTC
Permalink
Thanks Oleg for your help !
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Is this approximation acceptable ?
context.setAttribute(CONTEXT_ATTRIBUTE_RECEIVED_BYTES,
metrics.getReceivedBytesCount()+
(entity != null ? entity.getContentLength(): 0L));
It depends what consider acceptable but this will produce complete
garbage for chunked messages as their entity content length is always
-1.
Oleg
Post by Philippe Mouawad
Post by Philippe Mouawad
I am looking for raw content length
This cannot be done reliably with HttpClient 4.x (or I cannot think of
a way at the moment) as it requires a direct access to the
underlying
connection. It would require dropping to HttpCore level and a manual
connection management.
Oleg
Post by Philippe Mouawad
org>
Post by Oleg Kalnichevski
onsu
ltin
g.com>
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello Oleg,
Thanks for rapid answer.
The body size including entity.
Should this number represent raw bytes (including the size
of
transfer
encoding elements)
Can you illustrate so that I am sure to understand what you mean
by
size of
transfer
encoding elements ?
---
HTTP/1.1 200 OK\r\n
Content-Length: 5\r\n
\r\n
stuff
---
total message length: 43
raw content length: 5
content length: 5
---
HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
\r\n
5\r\n
stuff0\r\n
\r\
n
---
total message length: 60
raw content length: 16
content length: 5
What number are you after?
Oleg
Post by Oleg Kalnichevski
or content bytes only (same of Content-Length when
present)?
It would be much easier if you took the size of the entire message.
How should I proceed ?
Post by Oleg Kalnichevski
Oleg
Post by Philippe Mouawad
I'd like the header size to be aside, I already know how to
compute
header
size.
Regards
On Fri, Apr 20, 2018 at 11:21 AM, Oleg Kalnichevski <oleg
ache
.org
Post by Oleg Kalnichevski
Post by Philippe Mouawad
Hello ,
In current Live version of JMeter we use this way of
computing
size
of
-
https://github.com/apache/jmeter/blob/v4_0/src/pro
toco
l/ht
tp/o
rg/a
pache/jmeter/protocol/http/sampler/HTTPHC4Impl.java#L
888
As we migrated to last APIs we based implementation on
this
SO
response
-
https://stackoverflow.com/questions/26166469/measu
re-b
andw
idth
-usa
ge-with-apache-httpcomponents-httpclient
-
https://github.com/apache/jmeter/blob/trunk/src/pr
otoc
ol/h
ttp/
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
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_RE
CEIV
ED_B
YTES
,
metrics.getReceivedBytesCount()+
(entity != null ?
0L));
metrics.reset();
return response;
}
Philippe
Are you trying to calculate the size of an entire
response
(message
head + message entity body) or a response entity only?
Oleg
Post by Philippe Mouawad
Is my understanding correct ? or am I missing
something ?
Thanks
Regards
-----------------------------------------------------
----
----
----
----
.apa
che.
org
hc.a
pach
e.or
g
---------------------------------------------------------
----
----
----
che.
org
pach
e.or
g
-------------------------------------------------------------
----
----
org
e.or
g
-----------------------------------------------------------------
----
g
---------------------------------------------------------------------
--
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

UBIK LOAD PACK Web Site <http://www.ubikloadpack.com/>

UBIK LOAD PACK on TWITTER <https://twitter.com/ubikloadpack>
Loading...