hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Lowe" <chris.lowe...@gmail.com>
Subject Re: Connection metrics with Http Client/Core
Date Sun, 23 Nov 2008 15:41:22 GMT
Thanks Oleg. I presume you meant something like this for getting at the
connection metrics?

new HttpResponseInterceptor() {

    public void process(final HttpResponse response,
                            final HttpContext context) throws HttpException,
IOException {

                final AbstractClientConnAdapter connAdaptor =
(AbstractClientConnAdapter)
                    context.getAttribute(ExecutionContext.HTTP_CONNECTION);

                HttpConnectionMetrics metrics = connAdaptor.getMetrics();

        // ...
    }
}


Looking at the GZip example, for other stats like TTFB etc I could place an
InputStream wrapper around the following line:

InputStream wrappedin = wrappedEntity.getContent();


But wouldn't potentially skew my results since presumably the InputStream
reference that I get is already wrapped a few times and is buffered?

Is there a way to get the genuine time to first byte from the underlying
socket?


BTW when I was looking at the GZip example, I added the code to my
multithreaded implementation. It worked well.  However, I tried running the
example with Charles HTTP proxy running so I could see the new headers
coming through.  Normally adding "-Djava.net.useSystemProxies=true" to the
JVM arguments routes all traffic through Charles but with HttpClient it did
not. Is there anything else that I need to do in order to use the system
proxy settings with HttpClient?


Cheers,

Chris.


2008/11/23 Oleg Kalnichevski <olegk@apache.org>

> Chris Lowe wrote:
>
>> Hello,
>>
>> I'd like to use HttpClient 4.0b1 and HttpCore 4.0b3 to create a stress
>> test
>> application from which I need to get the following stats:
>>
>> Connection hand shake time;
>> Time to first byte sent/recevied;
>> Time to last byte received;
>> Overall connection metrics - total bytes sent and received from all
>> connections.
>>
>> Regarding overall metrics, I've seen
>> DefaultHttpClientConnection.getMetrics() but I cannot see how I can access
>> this information through something like ThreadSafeClientConnManager.
>>
>> Could anyone offer some pointers as to how I might derive these stats?
>>
>> Cheers,
>>
>> Chris.
>>
>>
>
> Hi Chris
>
> You should add a custom protocol interceptor, which would be able to get
> hold of the underlying connection from the execution context
>
> Here is an example how one can extend HttpClient capabilities by adding
> custom protocol interceptors:
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientGZipContentCompression.java
>
> Hope this helps
>
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message