On 8/20/06, Roland Weber <[EMAIL PROTECTED]> wrote:
Are you talking about buffering in the client or in the server?
Are you talking about a progress bar at the client or at the server?

The answer to both questions is the server side.

This looks like server side. A user interface on the server side?

Yes, I'm developing a peer-to-peer file sharing utility (where every
peer is both a client and a server), hence the need to show all active
uploads and their transfer progress.

> Integer.parseInt(String.valueOf(fSharedFile.length())));

That's an awfully complex way to turn a long into an int.

Yeah, I agree. I'm sure there's a much better way of achieving it :).

I don't see the point in buffering a file entity. File entities use
their own buffer in writeTo().

This is exactly what I was trying to figure out. I wasn't sure whether
the buffering should be done while constructing the response or in the
Entity itself. I scoured the list of documentation to no avail. I also
did go through the source in order to understand the code structure,
also to no avail.

You do NOT use a data transmitter directly! At least not if you
want to talk HTTP. You use a HttpServerConnection that knows how
to send the status line and response headers before sending the
response body.

I see. I was trying out so many different things and they simply
didn't work. Out of frustration I decided to try the most fundamental
thing that the API provides, hence the aforementioned code.

Here is my advice, assuming you want a progress bar on the server side:

1. throw away the code snippet above

Will do.

2. study class ElementalHttpServer from the examples to understand
   how files are served:
http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/tags/4.0-alpha2/src/examples/org/apache/http/examples/ElementalHttpServer.java

I did use the above example as a starting point, and keep building on
top of it.

3. implement file serving without progress bar, based on what you've
   seen in ElementalHttpServer

Will do.

4. derive your own FileEntityWithProgressBar from the FileEntity,
   overriding the writeTo() method to update the progress bar

This is exactly what I've been looking for.

hope that helps,
  Roland

Thanks a lot Roland, I'm sure it does.

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

Reply via email to