You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Philippe Mouawad <pm...@apache.org> on 2018/04/20 09:09:46 UTC

Correct way of computing Response size

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

Re: Correct way of computing Response size

Posted by Philippe Mouawad <p....@ubik-ingenierie.com>.
Thanks Oleg for your help !

On Fri, Apr 20, 2018 at 3:41 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2018-04-20 at 15:29 +0200, Philippe Mouawad wrote:
> > 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
>
> > On Fri, Apr 20, 2018 at 3:28 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > > On Fri, 2018-04-20 at 15:01 +0200, Philippe Mouawad wrote:
> > > > 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
> > >
> > >
> > > > On Fri, Apr 20, 2018 at 2:58 PM, Oleg Kalnichevski <olegk@apache.
> > > > org>
> > > > wrote:
> > > >
> > > > > On Fri, 2018-04-20 at 14:31 +0200, Philippe Mouawad wrote:
> > > > > > On Fri, Apr 20, 2018 at 1:01 PM, Oleg Kalnichevski <oleg@ok2c
> > > > > > onsu
> > > > > > ltin
> > > > > > g.com>
> > > > > > wrote:
> > > > > >
> > > > > > > On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> > > > > > > > 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
> > > > >
> > > > >
> > > > > >
> > > > > > > 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 ?
> > > > > >
> > > > > > >
> > > > > > > Oleg
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > 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
> > > > > > > > k@ap
> > > > > > > > ache
> > > > > > > > .org
> > > > > > > > >
> > > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad
> > > > > > > > > wrote:
> > > > > > > > > > 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/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
> > > > > > > > > > from Oleg:
> > > > > > > > > >
> > > > > > > > > >    -
> > > > > > > > > >    https://stackoverflow.com/questions/26166469/measu
> > > > > > > > > > re-b
> > > > > > > > > > andw
> > > > > > > > > > idth
> > > > > > > > > > -usa
> > > > > > > > > > ge-with-apache-httpcomponents-httpclient
> > > > > > > > > >
> > > > > > > > > > And ended up with this:
> > > > > > > > > >
> > > > > > > > > >    -
> > > > > > > > > >    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
> > > > > > > > > > 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_RE
> > > > > > > > > > CEIV
> > > > > > > > > > ED_B
> > > > > > > > > > YTES
> > > > > > > > > > ,
> > > > > > > > > >                     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
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Is my understanding correct ? or am I missing
> > > > > > > > > > something ?
> > > > > > > > > >
> > > > > > > > > > Thanks
> > > > > > > > > >
> > > > > > > > > > Regards
> > > > > > > > >
> > > > > > > > > -----------------------------------------------------
> > > > > > > > > ----
> > > > > > > > > ----
> > > > > > > > > ----
> > > > > > > > > ----
> > > > > > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc
> > > > > > > > > .apa
> > > > > > > > > che.
> > > > > > > > > org
> > > > > > > > > For additional commands, e-mail: httpclient-users-help@
> > > > > > > > > hc.a
> > > > > > > > > pach
> > > > > > > > > e.or
> > > > > > > > > g
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > > ---------------------------------------------------------
> > > > > > > ----
> > > > > > > ----
> > > > > > > ----
> > > > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apa
> > > > > > > che.
> > > > > > > org
> > > > > > > For additional commands, e-mail: httpclient-users-help@hc.a
> > > > > > > pach
> > > > > > > e.or
> > > > > > > g
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > > -------------------------------------------------------------
> > > > > ----
> > > > > ----
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.
> > > > > org
> > > > > For additional commands, e-mail: httpclient-users-help@hc.apach
> > > > > e.or
> > > > > g
> > > > >
> > > > >
> > > >
> > > >
> > >
> > > -----------------------------------------------------------------
> > > ----
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > > g
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

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

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

Re: Correct way of computing Response size

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-04-20 at 15:29 +0200, Philippe Mouawad wrote:
> 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 

> On Fri, Apr 20, 2018 at 3:28 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Fri, 2018-04-20 at 15:01 +0200, Philippe Mouawad wrote:
> > > 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
> > 
> > 
> > > On Fri, Apr 20, 2018 at 2:58 PM, Oleg Kalnichevski <olegk@apache.
> > > org>
> > > wrote:
> > > 
> > > > On Fri, 2018-04-20 at 14:31 +0200, Philippe Mouawad wrote:
> > > > > On Fri, Apr 20, 2018 at 1:01 PM, Oleg Kalnichevski <oleg@ok2c
> > > > > onsu
> > > > > ltin
> > > > > g.com>
> > > > > wrote:
> > > > > 
> > > > > > On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> > > > > > > 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
> > > > 
> > > > 
> > > > > 
> > > > > > 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 ?
> > > > > 
> > > > > > 
> > > > > > Oleg
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > > 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
> > > > > > > k@ap
> > > > > > > ache
> > > > > > > .org
> > > > > > > > 
> > > > > > > 
> > > > > > > wrote:
> > > > > > > 
> > > > > > > > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad
> > > > > > > > wrote:
> > > > > > > > > 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/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
> > > > > > > > > from Oleg:
> > > > > > > > > 
> > > > > > > > >    -
> > > > > > > > >    https://stackoverflow.com/questions/26166469/measu
> > > > > > > > > re-b
> > > > > > > > > andw
> > > > > > > > > idth
> > > > > > > > > -usa
> > > > > > > > > ge-with-apache-httpcomponents-httpclient
> > > > > > > > > 
> > > > > > > > > And ended up with this:
> > > > > > > > > 
> > > > > > > > >    -
> > > > > > > > >    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
> > > > > > > > > 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_RE
> > > > > > > > > CEIV
> > > > > > > > > ED_B
> > > > > > > > > YTES
> > > > > > > > > ,
> > > > > > > > >                     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
> > > > > > > > 
> > > > > > > > > 
> > > > > > > > > Is my understanding correct ? or am I missing
> > > > > > > > > something ?
> > > > > > > > > 
> > > > > > > > > Thanks
> > > > > > > > > 
> > > > > > > > > Regards
> > > > > > > > 
> > > > > > > > -----------------------------------------------------
> > > > > > > > ----
> > > > > > > > ----
> > > > > > > > ----
> > > > > > > > ----
> > > > > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc
> > > > > > > > .apa
> > > > > > > > che.
> > > > > > > > org
> > > > > > > > For additional commands, e-mail: httpclient-users-help@
> > > > > > > > hc.a
> > > > > > > > pach
> > > > > > > > e.or
> > > > > > > > g
> > > > > > > > 
> > > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > 
> > > > > > ---------------------------------------------------------
> > > > > > ----
> > > > > > ----
> > > > > > ----
> > > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apa
> > > > > > che.
> > > > > > org
> > > > > > For additional commands, e-mail: httpclient-users-help@hc.a
> > > > > > pach
> > > > > > e.or
> > > > > > g
> > > > > > 
> > > > > > 
> > > > > 
> > > > > 
> > > > 
> > > > -------------------------------------------------------------
> > > > ----
> > > > ----
> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.
> > > > org
> > > > For additional commands, e-mail: httpclient-users-help@hc.apach
> > > > e.or
> > > > g
> > > > 
> > > > 
> > > 
> > > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > g
> > 
> > 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Correct way of computing Response size

Posted by Philippe Mouawad <p....@ubik-ingenierie.com>.
Is this approximation acceptable ?
context.setAttribute(CONTEXT_ATTRIBUTE_RECEIVED_BYTES,
                    metrics.getReceivedBytesCount()+
                    (entity != null ? entity.getContentLength(): 0L));

On Fri, Apr 20, 2018 at 3:28 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2018-04-20 at 15:01 +0200, Philippe Mouawad wrote:
> > 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
>
>
> > On Fri, Apr 20, 2018 at 2:58 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > > On Fri, 2018-04-20 at 14:31 +0200, Philippe Mouawad wrote:
> > > > On Fri, Apr 20, 2018 at 1:01 PM, Oleg Kalnichevski <oleg@ok2consu
> > > > ltin
> > > > g.com>
> > > > wrote:
> > > >
> > > > > On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> > > > > > 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
> > >
> > >
> > > >
> > > > > 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 ?
> > > >
> > > > >
> > > > > Oleg
> > > > >
> > > > >
> > > > >
> > > > > > 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 <olegk@ap
> > > > > > ache
> > > > > > .org
> > > > > > >
> > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> > > > > > > > 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/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
> > > > > > > > from Oleg:
> > > > > > > >
> > > > > > > >    -
> > > > > > > >    https://stackoverflow.com/questions/26166469/measure-b
> > > > > > > > andw
> > > > > > > > idth
> > > > > > > > -usa
> > > > > > > > ge-with-apache-httpcomponents-httpclient
> > > > > > > >
> > > > > > > > And ended up with this:
> > > > > > > >
> > > > > > > >    -
> > > > > > > >    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
> > > > > > > > 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_RECEIV
> > > > > > > > ED_B
> > > > > > > > YTES
> > > > > > > > ,
> > > > > > > >                     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
> > > > > > >
> > > > > > > >
> > > > > > > > Is my understanding correct ? or am I missing something ?
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > >
> > > > > > > > Regards
> > > > > > >
> > > > > > > ---------------------------------------------------------
> > > > > > > ----
> > > > > > > ----
> > > > > > > ----
> > > > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apa
> > > > > > > che.
> > > > > > > org
> > > > > > > For additional commands, e-mail: httpclient-users-help@hc.a
> > > > > > > pach
> > > > > > > e.or
> > > > > > > g
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > > -------------------------------------------------------------
> > > > > ----
> > > > > ----
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.
> > > > > org
> > > > > For additional commands, e-mail: httpclient-users-help@hc.apach
> > > > > e.or
> > > > > g
> > > > >
> > > > >
> > > >
> > > >
> > >
> > > -----------------------------------------------------------------
> > > ----
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > > g
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

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

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

Re: Correct way of computing Response size

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-04-20 at 15:01 +0200, Philippe Mouawad wrote:
> 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


> On Fri, Apr 20, 2018 at 2:58 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> 
> > On Fri, 2018-04-20 at 14:31 +0200, Philippe Mouawad wrote:
> > > On Fri, Apr 20, 2018 at 1:01 PM, Oleg Kalnichevski <oleg@ok2consu
> > > ltin
> > > g.com>
> > > wrote:
> > > 
> > > > On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> > > > > 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
> > 
> > 
> > > 
> > > > 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 ?
> > > 
> > > > 
> > > > Oleg
> > > > 
> > > > 
> > > > 
> > > > > 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 <olegk@ap
> > > > > ache
> > > > > .org
> > > > > > 
> > > > > 
> > > > > wrote:
> > > > > 
> > > > > > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> > > > > > > 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/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
> > > > > > > from Oleg:
> > > > > > > 
> > > > > > >    -
> > > > > > >    https://stackoverflow.com/questions/26166469/measure-b
> > > > > > > andw
> > > > > > > idth
> > > > > > > -usa
> > > > > > > ge-with-apache-httpcomponents-httpclient
> > > > > > > 
> > > > > > > And ended up with this:
> > > > > > > 
> > > > > > >    -
> > > > > > >    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
> > > > > > > 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_RECEIV
> > > > > > > ED_B
> > > > > > > YTES
> > > > > > > ,
> > > > > > >                     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
> > > > > > 
> > > > > > > 
> > > > > > > Is my understanding correct ? or am I missing something ?
> > > > > > > 
> > > > > > > Thanks
> > > > > > > 
> > > > > > > Regards
> > > > > > 
> > > > > > ---------------------------------------------------------
> > > > > > ----
> > > > > > ----
> > > > > > ----
> > > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apa
> > > > > > che.
> > > > > > org
> > > > > > For additional commands, e-mail: httpclient-users-help@hc.a
> > > > > > pach
> > > > > > e.or
> > > > > > g
> > > > > > 
> > > > > > 
> > > > > 
> > > > > 
> > > > 
> > > > -------------------------------------------------------------
> > > > ----
> > > > ----
> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.
> > > > org
> > > > For additional commands, e-mail: httpclient-users-help@hc.apach
> > > > e.or
> > > > g
> > > > 
> > > > 
> > > 
> > > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > g
> > 
> > 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Correct way of computing Response size

Posted by Philippe Mouawad <p....@ubik-ingenierie.com>.
I am looking for raw content length

On Fri, Apr 20, 2018 at 2:58 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2018-04-20 at 14:31 +0200, Philippe Mouawad wrote:
> > On Fri, Apr 20, 2018 at 1:01 PM, Oleg Kalnichevski <oleg@ok2consultin
> > g.com>
> > wrote:
> >
> > > On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> > > > 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
>
>
> >
> > > 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 ?
> >
> > >
> > > Oleg
> > >
> > >
> > >
> > > > 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 <olegk@apache
> > > > .org
> > > > >
> > > >
> > > > wrote:
> > > >
> > > > > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> > > > > > 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/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
> > > > > > from Oleg:
> > > > > >
> > > > > >    -
> > > > > >    https://stackoverflow.com/questions/26166469/measure-bandw
> > > > > > idth
> > > > > > -usa
> > > > > > ge-with-apache-httpcomponents-httpclient
> > > > > >
> > > > > > And ended up with this:
> > > > > >
> > > > > >    -
> > > > > >    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
> > > > > > 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_B
> > > > > > YTES
> > > > > > ,
> > > > > >                     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
> > > > >
> > > > > >
> > > > > > Is my understanding correct ? or am I missing something ?
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > Regards
> > > > >
> > > > > -------------------------------------------------------------
> > > > > ----
> > > > > ----
> > > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.
> > > > > org
> > > > > For additional commands, e-mail: httpclient-users-help@hc.apach
> > > > > e.or
> > > > > g
> > > > >
> > > > >
> > > >
> > > >
> > >
> > > -----------------------------------------------------------------
> > > ----
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > > g
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

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

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

Re: Correct way of computing Response size

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-04-20 at 14:31 +0200, Philippe Mouawad wrote:
> On Fri, Apr 20, 2018 at 1:01 PM, Oleg Kalnichevski <oleg@ok2consultin
> g.com>
> wrote:
> 
> > On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> > > 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


> 
> > 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 ?
> 
> > 
> > Oleg
> > 
> > 
> > 
> > > 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 <olegk@apache
> > > .org
> > > > 
> > > 
> > > wrote:
> > > 
> > > > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> > > > > 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/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
> > > > > from Oleg:
> > > > > 
> > > > >    -
> > > > >    https://stackoverflow.com/questions/26166469/measure-bandw
> > > > > idth
> > > > > -usa
> > > > > ge-with-apache-httpcomponents-httpclient
> > > > > 
> > > > > And ended up with this:
> > > > > 
> > > > >    -
> > > > >    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
> > > > > 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_B
> > > > > YTES
> > > > > ,
> > > > >                     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
> > > > 
> > > > > 
> > > > > Is my understanding correct ? or am I missing something ?
> > > > > 
> > > > > Thanks
> > > > > 
> > > > > Regards
> > > > 
> > > > -------------------------------------------------------------
> > > > ----
> > > > ----
> > > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.
> > > > org
> > > > For additional commands, e-mail: httpclient-users-help@hc.apach
> > > > e.or
> > > > g
> > > > 
> > > > 
> > > 
> > > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > g
> > 
> > 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Correct way of computing Response size

Posted by Philippe Mouawad <p....@ubik-ingenierie.com>.
On Fri, Apr 20, 2018 at 1:01 PM, Oleg Kalnichevski <ol...@ok2consulting.com>
wrote:

> On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> > 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 ?


> 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 ?

>
> Oleg
>
>
>
> > 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 <olegk@apache.org
> > >
> > wrote:
> >
> > > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> > > > 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/o
> > > > rg/a
> > > > pache/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
> > > > -usa
> > > > ge-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;
> > > >         }
> > > >
> > >
> > > Philippe
> > >
> > > Are you trying to calculate the size of an entire response (message
> > > head + message entity body) or a response entity only?
> > >
> > > Oleg
> > >
> > > >
> > > > Is my understanding correct ? or am I missing something ?
> > > >
> > > > Thanks
> > > >
> > > > Regards
> > >
> > > -----------------------------------------------------------------
> > > ----
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > > g
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

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

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

Re: Correct way of computing Response size

Posted by Oleg Kalnichevski <ol...@ok2consulting.com>.
On Fri, 2018-04-20 at 11:40 +0200, Philippe Mouawad wrote:
> 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



> 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 <olegk@apache.org
> >
> wrote:
> 
> > On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> > > 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/o
> > > rg/a
> > > pache/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
> > > -usa
> > > ge-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;
> > >         }
> > > 
> > 
> > Philippe
> > 
> > Are you trying to calculate the size of an entire response (message
> > head + message entity body) or a response entity only?
> > 
> > Oleg
> > 
> > > 
> > > Is my understanding correct ? or am I missing something ?
> > > 
> > > Thanks
> > > 
> > > Regards
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.or
> > g
> > 
> > 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Correct way of computing Response size

Posted by Philippe Mouawad <p....@ubik-ingenierie.com>.
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


On Fri, Apr 20, 2018 at 11:21 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> > 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/a
> > pache/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-usa
> > ge-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;
> >         }
> >
>
> Philippe
>
> Are you trying to calculate the size of an entire response (message
> head + message entity body) or a response entity only?
>
> Oleg
>
> >
> > Is my understanding correct ? or am I missing something ?
> >
> > Thanks
> >
> > Regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.
Ubik-Ingénierie

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

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

Re: Correct way of computing Response size

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-04-20 at 11:09 +0200, Philippe Mouawad wrote:
> 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/a
> pache/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-usa
> ge-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;
>         }
> 

Philippe

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

Oleg

> 
> Is my understanding correct ? or am I missing something ?
> 
> Thanks
> 
> Regards

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org