CGI Upload in forked child-thread

  • Thread starter Carsten Broschek
  • Start date
C

Carsten Broschek

Hi!

Is it possible to handle a file upload via CGI through a
background-thread in order to show process-info? If the server reads
complete request and stores data into temp-file, there would be no sense
to fork the process?

My idea
1) send multipart
2) create session, fork process
3) parent writes html reponse "upload in process", with some meta-refresh
4) child process reads file-handle and writes into file
5) upload state is stored into session


Thanks for comments.

Carsten
 
X

xhoster

Carsten Broschek said:
Hi!

Is it possible to handle a file upload via CGI through a
background-thread in order to show process-info? If the server reads
complete request and stores data into temp-file, there would be no sense
to fork the process?

You are right, I don't think there is much sense to fork a process, from
what you describe, anyway.
My idea
1) send multipart
2) create session, fork process
3) parent writes html reponse "upload in process", with some meta-refresh

I don't think the client will honor a meta-refresh until the client is done
uploading the data. You would probably have to have the *client* do the
"fork", which is a web-question (javascript? using "_blank" as the
target?) not a perl one. But if it does do a refresh into a cgi script, it
will cause the cgi-script to be run from scratch, not connect into the
previous spawned process of the earlier cgi invocation (well, you could
make that happen with a bit of work, but I don't see why you would need
to.)
4) child process reads file-handle and writes into file

Why not have one process read the file-handle, write into a file,
and send soothing messages to the client every 10K bytes of upload?
Use CGI's upload hook. Of course, you would be at the mercy of your
web-servers buffering, and the clients incremental rendering. But
it seems to work for me as long as I keep it simple.

Xho
 
C

Carsten Broschek

Why not have one process read the file-handle, write into a file,
and send soothing messages to the client every 10K bytes of upload?
Use CGI's upload hook. Of course, you would be at the mercy of your
web-servers buffering, and the clients incremental rendering. But
it seems to work for me as long as I keep it simple.

Xho
Ok, the main question should be - is it possible to generate the
http-response, before the file is uploaded. is there a a way to control
the buffering?

c.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top