Right. you also need to calculate what you send to the web server. So you need to calculate the request headers when you make a request. Then on the response you get response body size and header size. As far as I know thats all you need to account for. Maybe Oleg or someone else can verify.
On Wed, Aug 8, 2012 at 10:19 AM, Jean-Marc Spaggiari < [email protected]> wrote: > Hi Ryan, > > This will calculate the header size. But is there anything else? Is > the size only headers + URL lenght for the request, and > headers+respons body for the respons? Is there any other CRC, > validation, packet, etc.? > > Because headersize + body lenght seems to not be accurate :( > > 2012/8/8, Ryan Smith <[email protected]>: > > If HttpClient has a method to do this, can someone let me know? This is > a > > method I wrote to calculate header size: > > > > public static int getHeaderByteSize(Header[] headers) { > > int requestHeaderByteSize = 0; > > for (Header requestHeader : headers) { > > if (requestHeader.getName() != null) { > > requestHeaderByteSize += requestHeader.getName().getBytes().length; > > } > > if (requestHeader.getValue() != null) { > > requestHeaderByteSize += requestHeader.getValue().getBytes().length; > > } > > } > > return requestHeaderByteSize; > > } > > > > On Wed, Aug 8, 2012 at 10:07 AM, Jean-Marc Spaggiari < > > [email protected]> wrote: > > > >> Hi, > >> > >> Is there a good way to calculate the bandwidth used by a request? > >> > >> I'm doing a get and I try to track the upload and download bandwidth > >> used. > >> > >> So for a get, there is some upload to the server. There is the URL, > >> and the headers. But seems there is a bit more than that and I'm not > >> able to figure what. > >> > >> When I get the respons, I'm using getHeaders("Content-Length") to get > >> the content lenght. But I'm most probably missing the header size. I > >> also tried EntityUtils.toString(entity).length() but none of them > >> seems to be accurate. > >> > >> So I'm wondering is there is a good way to calculate the bandwidth > >> used for upload and download? > >> > >> Thanks, > >> > >> JM > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
