DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27366>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27366

GetMethod.getResponseBodyAsStream() .available() could return content-length

           Summary: GetMethod.getResponseBodyAsStream() .available() could
                    return content-length
           Product: Commons
           Version: 2.0 Final
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: HttpClient
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


It would be nice if the InputStream returned from
GetMethod.getResponseBodyAsStream() could override the available()
method to return the content-length of the requested URL.  This would
make things like ProgressMonitorInputStream useful for monitoring the
progress of a download.  Here is a code snippet:


/**
 * 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;
  }
} 



Also, somewhat related to this request, could
GetMethod.getResponseContentLength() must be made public?  Is there a
good reason for it to be protected?  I had to extend GetMethod and
implement a public getResponseContentLength() in order to feed that
value to my FixedInputStream.

Thanks for your time.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to