How to calculate the data transfered over a HTTP Connection


I am working on a mobile application that will transfer data to a server but in order to calculate the cost for the transfer ie. Network data charge, I need to know the complete amount of data transfered including header, body content and response etc.

How can this be done?

Using: Java in NetBeans 5.5.1 with Apache 5.5.17

Thanks for your help
Who is Participating?
Probably the best thing to do is to use a loggable proxy
do you mean the request or the response data?
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

DudachAuthor Commented:
I am looking to calculate the number of bytes being received at the server.

What I have on the server side is:
ServletInputStream in = request.getInputStream();
DataInputStream din = new DataInputStream(in);

But I want to get the number of bytes in the DataInputStream din. How can this be done?

Thanks in advance

>>But I want to get the number of bytes in the DataInputStream din. How can this be done?

By reading it and counting them as it's read
number_of_bytes += din.length;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.