commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thoralf Rickert <>
Subject HTTPClient Feature Patch
Date Fri, 21 Feb 2003 08:15:30 GMT

I'm not subribed to the list, so please make a CC to my address...

I'm working on a small WebDAV application based on the org.apache.webdav 
library. For user feedback it is necessary to know how many bytes a Put 
request has already finished (0%...25%...50%...75%...100%) (especially 
for big files). Because the WebDAV PutMethod extends the httpclient 
PutMethod which extends the
I would like to "submit" a small patch, which makes it possible to get 
the number of already sent bytes in a "controlling thread"....Here is 
the code:

package org.apache.commons.httpclient.methods;
public abstract class EntityEnclosingMethod extends GetMethod {
   private long writtenBytes = 0;
   protected boolean writeRequestBody(HttpState state,
                                      HttpConnection conn)
       throws IOException, HttpException {

     writtenBytes = 0;
     byte[] tmp = new byte[4096];
     //int total = 0;
     int i = 0;
     while ((i = >= 0) {
       outstream.write(tmp, 0, i);
       //total += i;
       writtenBytes += i;

    * Returns the Number of Request Body Bytes send to the server
   public long getWrittenRequestBodyBytes() {
     return this.writtenBytes;

If I would start the HttpConnection in a subthread I could call the 
getWrittenRequestBodyBytes() method (or however you call it) during 
upload to get the number of transfered bytes. So I can show the user, 
that the application still works...

Do you think, that this small patch is useful for you too or do you know 
another way?

Thoralf Rickert

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

View raw message