You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Randy Paries <ra...@unitnet.com> on 2005/09/23 17:36:18 UTC

Can I use HttpClient to calculate the size of a web page?

Hello,
 
I am looking for some suggestions.
 
I have a application that a user uses an in-browser editor and then saves
their page to a servlet which creates the html file.
 
I need to determine how large this page is (ie how long it would take to
download for a dialup user).  So image size needs to be calculated etc.
 
So i was thinking how right after saving the file, i would have the servlet
use a httpClient and re-read it.
 
    //abbreviated version //
            HttpClient client = new HttpClient();
            method = new GetMethod(url);
            int statusCode = client.executeMethod(method);
            byte[] responseBody = method.getResponseBody();
            return responseBody.length;

but this really just returns the html text
 
Can httpClient do what i want? or does any one have a great idea for me?
 
Thanks
Randy