Sending a "status"

Discussion in 'Perl Misc' started by Bill H, Aug 17, 2007.

  1. Bill H

    Bill H Guest

    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
     
    Bill H, Aug 17, 2007
    #1
    1. Advertising

  2. 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
     
    Jürgen Exner, Aug 17, 2007
    #2
    1. Advertising

  3. 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 <table>. At
    > second you must send many (useless) spaces to fill browser buffer.
    >
    > $|=1;
    > print "<p>Saving your data...</p>, ' 'x1024; # do something
    > print "<p>Processing your data......</p>, ' '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
     
    Martijn Lievaart, Aug 18, 2007
    #3
  4. 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
     
    Martijn Lievaart, Aug 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. saha
    Replies:
    0
    Views:
    4,069
  2. Shug
    Replies:
    13
    Views:
    902
    Philipp
    Dec 15, 2006
  3. Shug
    Replies:
    13
    Views:
    957
    Philipp
    Dec 15, 2006
  4. harryos
    Replies:
    0
    Views:
    388
    harryos
    Oct 13, 2010
  5. Sven S.

    status info like rc.status

    Sven S., Dec 9, 2008, in forum: Ruby
    Replies:
    2
    Views:
    180
    Sven S.
    Dec 11, 2008
Loading...

Share This Page