httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject File Upload Problem with CGI
Date Fri, 03 May 2002 14:59:12 GMT
I am having problems uploading files to cgi scripts to be processed and
sent back to the client.  In the simplest case (just using it for
troubleshooting the problem) I have a python script that reads all data in
from stdin and writes it back out to stdout.  If I upload files larger than
about 8k to this script it hangs.  If I turn up debugging in the httpd.conf
file I see that after 5 minutes (the configured timeout for my apache
server) an error message shows up saying "copy script args timed out".
This error message seems to me to come from within mod_cgi when it tries to
copy data from the client to the cgi script.  If I send the same file to
the python script above but comment out the line that would write data back
to stdout it works fine.  I have also tried writing a c program to do the
same thing as the python script with similar results.  I noticed a similar
posting in one of the newsgroups about a year ago, but the person was using
perl and all of the recommendations centered around changing cgi modules.

The following python code hangs:

import sys

blockSize=1024 #Changing this does cause the script
                                #to get farther (or not as far) but it
still hangs.

sys.stdout.write('Content-Type: text/plain\n\n")

while 1:
   if(not dataLine): break
   sys.stdout.write(dataLine) #If I comment this out it runs ok so
                                                      #the problem to me
seems to be
                                                      #related to reading &
writing at same time.


The following c code hangs:

#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
   char buff[1024];

   fputs("Content-Type: text/plain\n\n", stdout);

   while(fgets(buff, sizeof(buff), stdin) != NULL)
      fputs(buff, stdout);

All of the above examples work with small files (at most 16k or so) but
seem to hang with files that are larger than that.  Any ideas?

Thanks in advance for your help,

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

View raw message