I would like to be able to allow the user to view the output of a long GCI script as it is created, and not after the script completes. However, even when I explicitly hide STDOUT, the server seems to be waiting for the script to complete before sending a response to the client. This is on a Linux server with Apache 2.2.9.
CGI python example:
#!/usr/bin/python import time import sys print "Content-type: text/plain" print for i in range(1, 10): print i sys.stdout.flush() time.sleep(1) print "Done."
A similar example in perl:
#!/usr/bin/perl print "Content-type: text/plain\n\n"; for ($i = 1; $i <= 10 ; $i++) { print "$i\n"; sleep(1); } print "Done.";
This link says that the output of Apache 1.3 CGI should be unbuffered (but this can only apply to Apache 1.x): http://httpd.apache.org/docs/1.3/misc/FAQ-F.html#nph- scripts
Any ideas?
python perl apache2 cgi
Dave forgac
source share