Re: Creating a "Progress" page with CGI
by merlyn (Sage) on Dec 06, 2005 at 18:54 UTC
|
| [reply] |
|
|
Hi Randal,
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. :(
The method to use now is forking the process in the background and providing updates. Roy Johnson provides the link to the redirection discussion.
Update: I remembered my tests wrong. My apologies to Merlyn.
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
| [reply] |
|
|
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?
| [reply] |
|
|
|
|
Re: Creating a "Progress" page with CGI
by Roy Johnson (Monsignor) on Dec 06, 2005 at 18:54 UTC
|
| [reply] |
Re: Creating a "Progress" page with CGI
by dragonchild (Archbishop) on Dec 06, 2005 at 19:33 UTC
|
The cleanest solution I've seen to this problem is the following:
- Create two divs on your page. One contains a GIF-89 that has some neat status indicator that repeats. The second contains your data and starts out as display: none;
- Immediately render the first div and the beginning of the second div. This way, your user sees something.
- As you get results, render them right away so as to keep the connection alive.
- After you finish rendering, hide the first and show the second div.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |
|
|
That reminds me of a CGI progress information using Javascript I did a little while ago.
dragonchild, your solution is more applicable when you don't have anything specific to say about how you're actually getting along in your pgorewss, but you just want an indicator anyway.
| [reply] |
Re: Creating a "Progress" page with CGI
by Celada (Monk) on Dec 06, 2005 at 18:56 UTC
|
I have to guess what order you're doing things in because you didn't provide any sample code, but I suppose you're sending output back to the client including the magic popup before you start the system action? Did you set $| to 1 to make sure that output would not be buffered up inside Perl?
By the way, your users might apreciate it better if you just update them on the status of their request in the original browser window rather than popping up a new one.
| [reply] [d/l] [select] |