Tao Li wrote:
> 
> Hi Bill,
> 
> Thanks a lot for your codes. But I found it doesn't work also. And I found this
> from apache's website:
> 
> "Apache for Windows version 1.3 series is implemented in synchronous calls. This
> poses an enormous problem for CGI authors, who won't see unbuffered results sent
> immediately to the browser. This is not the behavior described for CGI in Apache,
> but it is a side-effect of the Windows port. Apache 2.0 is making progress to
> implement the expected asynchronous behavior, and we hope to discover that the
> NT/2000 implementation allows CGI's to behave as documented."
> 
> Does this mean I should use Unix based server in order to get real time output
> of CGI program? Even the following simple program doesn't work on  my system.
> (NT+apache 1.3+active perl 5.6)
> 
> #!c:/web/perl/bin/perl -w
> $| = 1;
> 
> print "Content-type: text/html\n\n";
> 
> for ($i=1;$i<10;$i++) {
>         print " Current number is $i ";
>         sleep 1;
>         }

The above code won't work and is not what I proposed below.  Did you try the 
proposed code ?  If so, what result did you get ?

Like I said below the code will work for Netscape and MSIE will keep drawing 
the overlaid part down the page (so instead of seeing the line replaced, you 
will see successive versions of it all on the screen at once).  The reason 
the code below will work is because it forces out data in enough quantity 
that it flushes out the buffers to the browser.  Notice the 4K block of 
spaces I'm using to flush the buffers (less may work, I just used 4K since 
I didn't want to spend time determining how big the buffers are).  You can 
experiment with the size and delay.

I tested the code using Apache 1.3 on Win98SE.

> >This should work in Netscape - MSIE will not redraw:
> >
> >nph-script.pl (should require nph- prefix):
> >
> >#!c:\web\perl\bin\perl
> >
> >$| = 1;
> >
> >my $boundary = "MyBoUnDaRy";
> >my $mime_type = "multipart";
> >my $mime_subtype = "x-mixed-replace";
> >
> >print "HTTP/1.0 200 OK\n";
> >print qq{Content-Type: multipart/x-mixed-replace; boundary="$boundary"\n\n};
> >
> >for (1 .. 10) {
> >
> >       print <<EOD;
> >--$boundary
> >Content-type: text/plain
> >
> >$_: ddddd
> >EOD
> >       sleep 5;
> >
> >       print ' ' x 4096;       # flush buffer out
> >       print "--$boundary--\n";
> >       sleep 5;
> >}
> >
> >__END__
> >
> >You can play around with where the sleep and extra spaces go.

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED] 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to