Question

I have a small cgi script that fetches and validates a configuration file for Nagios. The typical run time is several minutes, and I would like to get some feedback in the browser during the run.

To illustrate what I would like to happen, consider this:

#!/bin/sh
echo "Content-type: text/plain"
echo

for i in A B C D E
do
        echo $i
        sleep 10
done

When I do a GET on this script via telnet or with wget, the output comes one row at a time, with ten second intervals ("A"... "B"... "C"... and so on).

When I try to open it in a common browser, the browser seems to buffer it all and present the output when the script is done (50 seconds of silence... "ABCDE").

Is it possible to make the browser present the data to the user as soon as it has arrived?

Was it helpful?

Solution

I believe what you want is to use "html chunk encoding". This lets the server send the browser a "chunk" of HTML that it can start rendering. ASP & ASP.Net take care of this for you whenever you use "Response.Write".

Here are some references:

OTHER TIPS

Use Wireshark.

Use Response.Flush() after you have written enough to the response buffer....

http://www.stephanunrau.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top