Sending a "status"

Sending a "status"

am 17.08.2007 15:48:00 von Bill H

Using $|++ I have learned that I can "flush" the print buffer to a
browser while perl is doing things, instead of sending all the html
when it is done. Is there any drawbacks to using this in the real
world that any of you may have encountered?

Basically what I would be doing is sending a status to a client while
the perl scripts are working such as (after sending the html headers
and other stuff):

Saving your data...
Processing your data...
Generating completed pdf...
Complete.

etc...

and then sending the ending html data.

Bill H

Re: Sending a "status"

am 17.08.2007 15:55:51 von jurgenex

Bill H wrote:
> Using $|++ I have learned that I can "flush" the print buffer to a
> browser while perl is doing things, instead of sending all the html
> when it is done. Is there any drawbacks to using this in the real
> world that any of you may have encountered?
>
> Basically what I would be doing is sending a status to a client while
> the perl scripts are working such as (after sending the html headers
> and other stuff):
>
> Saving your data...
> Processing your data...
> Generating completed pdf...
> Complete.
>
> etc...
>
> and then sending the ending html data.

Not that you question has anything to do with Perl, but you do realize, that
the browser is not obligated to display incomplete HTML pages? Many will
wait until the complete page has been received before beginning to render
it.

jue

Re: Sending a "status"

am 17.08.2007 16:02:30 von Christian Winter

Bill H wrote:
> Using $|++ I have learned that I can "flush" the print buffer to a
> browser while perl is doing things, instead of sending all the html
> when it is done. Is there any drawbacks to using this in the real
> world that any of you may have encountered?
>
> Basically what I would be doing is sending a status to a client while
> the perl scripts are working such as (after sending the html headers
> and other stuff):
>
> Saving your data...
> Processing your data...
> Generating completed pdf...
> Complete.
>
> etc...
>
> and then sending the ending html data.

There may be scenarios where this won't work as expected,
e.g. if the user's behind a proxy. Not every http proxy
forwards incomplete responses, especially in company networks
the proxy often fetches the whole response and does checks
(antivirus, buzzwords etc.) on it before serving it to the
client.

Another thing is that you have to watch your maximum script
run time settings in the server, though that's always the
point with long running scripts.

Otherwise, with pure HTML, there shouldn't be big problems
with unbuffered output.

-Chris

Re: Sending a "status"

am 18.08.2007 04:58:54 von Petr Vileta

Bill H wrote:
> Using $|++ I have learned that I can "flush" the print buffer to a
> browser while perl is doing things, instead of sending all the html
> when it is done. Is there any drawbacks to using this in the real
> world that any of you may have encountered?
>
> Basically what I would be doing is sending a status to a client while
> the perl scripts are working such as (after sending the html headers
> and other stuff):
>
> Saving your data...
> Processing your data...
> Generating completed pdf...
> Complete.
>
> etc...
>
> and then sending the ending html data.
>
It is solvable but not for 100% ;-)
At first you must keep in mind that some html tags are displayed after end
tag only. For example you must not put messages into

.
At second you must send many (useless) spaces to fill browser buffer.

$|=1;
print "

Saving your data...

, ' 'x1024;
# do something
print "

Processing your data......

, ' 'x1024;

# do something

This work well (tested) for MSIE5.x and latter and Firefox 2.x and latter.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: Sending a "status"

am 18.08.2007 15:41:02 von Martijn Lievaart

On Sat, 18 Aug 2007 04:58:54 +0200, Petr Vileta wrote:

> Bill H wrote:
>> Using $|++ I have learned that I can "flush" the print buffer to a
>> browser while perl is doing things, instead of sending all the html
>> when it is done. Is there any drawbacks to using this in the real world
>> that any of you may have encountered?
>>
>> Basically what I would be doing is sending a status to a client while
>> the perl scripts are working such as (after sending the html headers
>> and other stuff):
>>
>> Saving your data...
>> Processing your data...
>> Generating completed pdf...
>> Complete.
>>
>> etc...
>>
>> and then sending the ending html data.
>>
> It is solvable but not for 100% ;-)
> At first you must keep in mind that some html tags are displayed after
> end tag only. For example you must not put messages into

. At
> second you must send many (useless) spaces to fill browser buffer.
>
> $|=1;
> print "

Saving your data...

, ' 'x1024; # do something
> print "

Processing your data......

, ' 'x1024;
>
> # do something
>
> This work well (tested) for MSIE5.x and latter and Firefox 2.x and
> latter.

To be more exact, some versions of IE don't display anything unless they
have received 256 characters (or the page is complete, obviously). So
send 256 spaces first and then start outputting the rest. No need to send
1024 spaces on every print.

M4

Re: Sending a "status"

am 18.08.2007 16:11:46 von Petr Vileta

Martijn Lievaart wrote:
>> $|=1;
>> print "

Saving your data...

, ' 'x1024; # do something
>> print "

Processing your data......

, ' 'x1024;
>>
>> # do something
>>
>> This work well (tested) for MSIE5.x and latter and Firefox 2.x and
>> latter.
>
> To be more exact, some versions of IE don't display anything unless
> they have received 256 characters (or the page is complete,
> obviously). So send 256 spaces first and then start outputting the
> rest. No need to send 1024 spaces on every print.
>
Yes, I found this information somewhere too, but in real this is not true
:-) Some MSIE (maybe some 6.x) need 512 bytes and some Firefox need a little
more so I send 1024 everytime and this work for most browsers. All browsers
trash redundant spaces and show only one.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: Sending a "status"

am 19.08.2007 08:51:02 von Martijn Lievaart

On Sat, 18 Aug 2007 16:11:46 +0200, Petr Vileta wrote:

> Martijn Lievaart wrote:
>> To be more exact, some versions of IE don't display anything unless
>> they have received 256 characters (or the page is complete, obviously).
>> So send 256 spaces first and then start outputting the rest. No need to
>> send 1024 spaces on every print.
>>
> Yes, I found this information somewhere too, but in real this is not
> true :-) Some MSIE (maybe some 6.x) need 512 bytes and some Firefox need
> a little more so I send 1024 everytime and this work for most browsers.
> All browsers trash redundant spaces and show only one.

Ah, thanks. Sending 256 spaces "worked for me" up to now, but I like to
stay on the safe side an will follow your advice.

M4