in reply to Re^2: Creating a "Progress" page with CGI
in thread Creating a "Progress" page with CGI

The "Lines 1 through 3 begin nearly every CGI program I write: enabling taint checking, compiler restrictions, and disabling the buffering of standard output." in your article doesn't hold true any more for Apache 2. Specifically the "$|++;" which does disable the buffering at the perl level but not within Apache v2. :(
Uh, you're apparently confused. I'm unbuffering the connection between the forked Perl process and Apache. That doesn't matter whether it's Apache 1 or Apache 2. That's to keep unbuffered and buffered output from intermixing badly to STDOUT, so that the header doesn't appear after some of the body content, for example.
The method to use now is forking the process in the background and providing updates. Roy Johnson provides the link to the redirection discussion.
And the technique shown is indeed "fork and continue the process in the background". Did you read the article?

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on Re^3: Creating a "Progress" page with CGI

Replies are listed 'Best First'.
Re^4: Creating a "Progress" page with CGI
by jfroebe (Parson) on Dec 06, 2005 at 19:15 UTC

    Hi Randal,

    Actually I did many times both on the web and also in the book. Anyways, I didn't explain myself clearly enough. Sorry about that. With Apache 2, the unbuffering at the perl level doesn't seem to make any difference (atleast with my testing).

    update: nevermind. I remembered my test wrong. ugh.. must be too close to monday

    Jason L. Froebe

    Team Sybase member

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

      The difference is for programs like this:
      #!/usr/bin/perl ## uncomment this: ## $|++; print "content-type: text/plain\n\n"; system "date";
      When left commented, this fails (under both apache 1 and 2) because the system date comes out before the header, causing a 500 error.

      When uncommented, it works correctly.

      This is what I'm talking about. You were probably testing something else, like whether you could see it all the way through to the browser. That's a different problem, and was never related to my use of $|++.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.