Re: how to flush STDOUT before end of script

Felix Morley Finch (
Wed, 29 Jan 1997 19:01:25 -0800

Date: Wed, 29 Jan 1997 19:01:25 -0800
Message-Id: <>
From: Felix Morley Finch <>
To: Echo <>
Subject: Re: how to flush STDOUT before end of script 
In-Reply-To: <> (message 

>>In article <>, Echo 
<> writes:

> I installed fcgi with apache 1.2b6 with perl ..
>  but I'am quite dispointed because apache wait for the end of the script
> execution before sending the whole page. 
> In this cas I see almost nodifference with a normal cgi script.

> for instance :

> while(FCGI::Accept() >=0)
> {
> $|=1;
> print "fisrt";
> sleep 10;
> print "second";
> }

I believe this is standard server procedure.  Don't know why, seems
like more trouble, but there is a way around it.  Has nothing to do
with FastCGI, BTW.

If you've got the O'Reilly book CGI programming, check page 139ff.
Here is my capsule (possibly incomplete and/or in error!) summary:

A standard HTML document begins with "Content-type: test/html", a
blank line, then the <HTML><BODY>...</BODY></HTML> stuff.  But you can
preface this with mime-type lines specifying multipart and what the
divider is, then each block of data, *including* the normal
Content-type: line, blank line, and <HTML>...</HTML>, another blank
line, and an extra line with the divider.  Repeat this last for every
separate block you want.  The final block's divider line has a special
syntax, telling the browser that there are no more parts.

Like this:

	Content-type: multipart/x-mixed-replace;boundary=Xyzzy

	Content-type: text/html

	...first part...

	Content-type: text/html

	...middle part...

	Content-type: text/html

	...last part...


"Xyzzy" can be and boundary marker you want.

Notice the extra "--" after the final boundary marker.

You can also mix in pictures and all; change the Content-type: header,
replace the <HTML>...</HTML> with your gif, and make sure you keep the
blank lines around the gif.

I hope I haven't screwed this up *too* much...

     ... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
       Felix Finch, scarecrow repairer /
     PGP = 9D 93 1E 78 5B D7 42 1C   95 4E 9E DD 3F 6F 21 98
I've found a solution to Fermat's Last Theorem but I see I've run out of room o