commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: [HttpClient] GetMethod.getResponseBody().available() for download estimation?
Date Tue, 02 Mar 2004 13:18:26 GMT
Hi George,

Please file an enhancement request in Bugzilla.  This change could most 
likely be made in the post 2.0 code.  As a side note, the content 
length (if present) can be read from the response headers.

Mike

On Mar 2, 2004, at 7:20 AM, George Armhold wrote:

> Well I've been able to get a ProgressMonitorInputStream working with
> GetMethod.  I can now get a ProgressMonitor to pop up for my
> downloads.  I've had to wrap the InputStream returned from
> getResponseBodyAsStream() with a FilterInputStream that returns the
> contentLength for available().  I also had to extend GetMethod to make
> getResponseContentLength() public.  Why is it protected??  This is
> kind of ugly, but it works.
>
> /**
>  * supply a hard-coded value for available() method.
>  */
> class FixedInputStream extends FilterInputStream {
>   private int contentLength;
>
>   public FixedInputStream(InputStream is,
> 			  int contentLength) {
>     super(is);
>     this.contentLength = contentLength;
>   }
>
>   public int available() throws IOException {
>     return contentLength;
>   }
> }
>
> /**
>  * expose protected method getResponseContentLength.
>  */
> class FixedGetMethod extends GetMethod {
>
>   public FixedGetMethod(String url) {
>     super(url);
>   }
>
>   public int getResponseContentLength() {
>     return super.getResponseContentLength();
>   }
> }
>
>
>
> -- 
> George Armhold
> Rutgers University
> eLearning Grant, DCIS
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message