On Wednesday 28 December 2005 15:24, Tilmann Singer wrote:
> Even if I could not convince you now why I prefer normal http upload,
> could someone make a guess wether it would be possible to implement
> the "ns_info conn $threadid" command in an aolserver module? Or is a
> core modification required? And coming back to the original question,
> does Aolserver 4.5 offer anything new in this regard?

This is an interesting area. HTTP only offers two encodings for form data. The 
one used for files is multipart/form-data. But the data is encoded and 
expands in size. It is also put into the POST format. The only way to get the 
file out is to use ns_conn file, etc.

There are problems on both the client and server side. Client browsers cannot 
send binary data. AOLserver loads the entire request before a connection 
thread is started. That means that there isn't any opportunity to save data 
in chunks, just in case something goes wrong during the lengthy upload.

One result of this is that, maybe, ns_conn will not have any data until all 
the request is finished being read from the sock. So you can't get a progress 
report from the server.

At any rate, core hacking will be required to do progress or recovery on the 
server, and would still require special application code.

So here is what I looked at. A simple tcl shell script (loading libnsd.so) 
that puts chunks of data to the AOLserver. Progress can be recorded and 
reported on the client side. This only solves the progress report.

What if you want to resume? One possibility is to write a simple server side 
program which will track multiple posts and append them to the correct file. 
In the case of a network error, a resume function could start up at the point 
of interruption. 

My simple script breaks the file down into chunks (say .5M) and sends them to 
the server. It would be easy to create separate requests for these chunks 
instead of shoving them down the same single connection. The advantage is 
that you get progress, recovery, plus you don't have to worry about AOLserver 
getting pissed off when the upload limit is breached. Downside is that you 
still have a client side program that someone has to learn to use.

At the moment the interface is:

./sock3.tcl /tmp/myfile.jpg

and you get something like this as a progress monitor:

Length of /tmp/images.tgz = 19849524
[........................................] finished writing 19849524

I tested with a one second delay (ns_sleep 1) between chunks and it seems to 
work fine like that (to simulate network congestion), as well as with one big 
chunk.

Since the upload is binary, there is no loss due to encoding, and the saved 
file is identical to the original without any need to decode.

Maybe with a little tk, things could be nice. 

I did try with plain old tcl socket, but it seemed to have a high rate of 
broken pipe errors, so I used ns_sockopen from libnsd.so.

Tom Jackson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to