Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I was wondering if anyone has seen issues with IE5.5 and output buffer
flushing with CGI.pm.  The script I have written generates a page,
redirects the browser to that page, then continues processing.  Netscape
4.x and IE5.0 are working, IE5.5 isn't.  Here is the code snipit:

#!/usr/local/perl/bin/perl

use CGI;

$q = new CGI;

...
...
Build html page (build array, open file, print array, close file)
...
...
$FLUSH = $|;
$| = 1;  # Turn off buffering

print $q->redirect(-uri=>"http://host.bla/OCFA/$USER.html");

$| = $FLUSH;
 
...
...
Continue processing.  Some of the processing after this point
uses system();

Any pointers would be appreciated.
  • Comment on CGI.pm Flushing and Internet Explorer 5.5

Replies are listed 'Best First'.
Re: CGI.pm Flushing and Internet Explorer 5.5
by Fastolfe (Vicar) on Nov 13, 2000 at 19:57 UTC
    I'm not quite sure what you mean by "IE5.5 isn't." What is it not doing? I'm assuming you mean it just hangs on the CGI page. If you're worried about buffering try telnetting to your web server by hand and request the CGI script. This would let you see what the browser sees.
    $ telnet www.example.com 80 GET /cgi-bin/script.pl HTTP/1.0
    (Hit return twice after the 2nd line.) I suspect that the redirect line is coming promptly, but since your script is still "pausing", the browser is waiting for it to complete any data the server/script is going to send with that request. Try either closing STDOUT or fork your script, with the child performing the additional processing and the parent cleaning up and exiting. This should allow the HTTP transaction to complete and the browser to follow through with the redirect request.
      Thanks a bunch for the help, especially with the telnet test.
      Here is what I did:
      ...
      ...
        $SIG{CHLD} = IGNORE;
      
        if ($PID = fork){
      
          $| = 1;
      
          print $q->redirect("http://somewhere.outthere/OCFA/$USER.html");
          exit(0);
      
        }elsif(defined $PID){
      
          open(STDERR,'>/dev/null');
          open(STDOUT,'>/dev/null');
      ...
      ...
      
      The control connection now closes right after the redirect
      is sent and 5.5 picks up the new page.  The child becomes
      a child of init and cleans up when it is through processing.
      I'm not certain the semantics are correct but the script is
      working.
      
      Thanks
(Ovid) Re: CGI.pm Flushing and Internet Explorer 5.5
by Ovid (Cardinal) on Nov 13, 2000 at 21:22 UTC
    Two things. First, you want to use local with $|. Second, try changing your syntax on the redirect:
    { $| = 1; # Turn off buffering print $q->redirect("http://host.bla/OCFA/$USER.html"); }

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just go the the link and check out our stats.