commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George Armhold <>
Subject [HttpClient] GetMethod.getResponseBody().available() for download estimation?
Date Tue, 02 Mar 2004 11:32:20 GMT

Is there any way to get an InputStream back from
GetMethod.getResponseBody() whose available() method returns a
reasonable estimation of the content-length of the requested resource?
I'm trying to use a ProgressMonitorInputStream to monitor a download,
but the available() method is returning something like 1K on a
multi-megabyte download.  The API docs state that available() should
return the amount of data that is available without blocking, so
perhaps this the amount of data that the underlying IO system has
buffered.  For what it's worth, I get the same results when I code the
thing by hand using a URLConnection.  BTW I did verify with a HEAD
request that the webserver was returning a valid content-length for
the URL I am using

Or perhaps there's a better way to get a download progress indicator?
Another idea is to do a HEAD request to get the content-length first,
then do my GetMethod, and override ProgressMonitorInputStream to
return the true content-length from available().  Thoughts?


George Armhold
Rutgers University
eLearning Grant, DCIS

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message