in reply to Autoflush and web browsers (was: Clever autoflush detail)

I don't do cgi, but surely the problem (being fixed by using PRE tags), is not at the output end, but at the browser end?

Normally, html ignores CR/LF. So, the browser cannot display the line until it gets something (like: BR or P) that tells it that this 'line' is complete and can be formatted. Using the PRE tags means that CR/LF is respected, so the browser can display the line as soon as it sees those characters.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: Clever autoflush detail
by talexb (Chancellor) on Jun 20, 2007 at 18:51 UTC
      Normally, html ignores CR/LF. So, the browser cannot display the line until it gets something (like: BR or P) that tells it that this 'line' is complete and can be formatted.

    Right, but I made a point of setting the content type to be text/plain (that is, specifically not to be HTML), and that worked correctly using the shell script, but not using the Perl script. That's why I'm confused.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        The first Perl script in my original post had 'text/plain'; that's the one that I'm talking about.

        And as blahblah correctly points out lower down, this appears to have something to do with CGI, because if I remove that dependency as follows:

        #!/usr/bin/perl -w $|=1; { print "Content-type: text/plain\n\n"; print "Autoflush is currently " . ($|?"on":"off") . ".\n"; for ( 1..5 ) { print "Value is $_.\n"; sleep 1; } print "Autoflush is currently " . ($|?"on":"off") . ".\n"; }

        The script works properly. So CGI is ignoring $| and doing its own caching. Now I know.

        Alex / talexb / Toronto

        "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds