How can I measure HttpClient's traffic?

469 views Asked by At

I have an application using Apache HttpClient 3.1. I want to know how much data the application sends and receives and I want to measure this "per thread" (i.e. I want to know how much data a specific thread sent and received).

I currently simply count the number of bytes received in the content, but that's not what I need. Traffic sent should include the request headers and traffic received should include the response headers... (many requests just return "OK" or an empty body so I think the headers make up for more than 50% of total traffic).

I would very much like a solution for HttpClient 3.1 since the upgrade to 4.x does not seem trivial and I'm otherwise happy with 3.1.

I've done some searching and found connection.getMetrics() which seems to exist only for 4.x :( If it really has to be 4.x, then how would I do it, I never explicitly handle connections, I currently simply call client.executeMethod(method); and then method.getResponseBodyAsStream()...

Thanks in advance for any help :)

0

There are 0 answers