I'm also on Windows. The code you presented finishes writing to a file, then it streams it.

Oops. Posted an older version of the code. In that older version, I was opening the HTML temp file, writing to it, then streaming the temp file. It does stream the full content, but it defeats the whole purpose, because you don't start streaming the file until the complete HTML has been printed to it.

I tried to address this issue by starting to stream the temp file right after it was opened, in the hopes that streaming from a file that is open for writing would work. In other words, I used this version of stream_dynamic_html:

sub stream_dynamic_html { my ($self) = @_; $| = 1; open TEMP_HTML_FILE, ">$temp_dynamic_html_fpath"; $self->stream_file($temp_dynamic_html_fpath, 10); my $q = $self->query(); print TEMP_HTML_FILE $q->start_html(-title => 'HTML page dynamical +ly streamed to scean'); print TEMP_HTML_FILE $q->h3('HTML page dynamically streamed to sce +an'); print TEMP_HTML_FILE $q->p("The following lines will be printed at + 1 sec interval."); for (my $ii=0; $ii<3; $ii++) { print TEMP_HTML_FILE $q->p("This is line $ii.\n"); sleep(1); } print TEMP_HTML_FILE $q->p()."\n"; print TEMP_HTML_FILE "<a href=\"$script_name?dlg=stream_dynamic_ht +ml\">Stream dynamic HTML page</a><br/>\n"; print TEMP_HTML_FILE "<a href=\"$script_name?dlg=stream_static_fil +e\">Stream static file</a><br/>\n"; print TEMP_HTML_FILE $q->end_html(); close TEMP_HTML_FILE; }

Unfortunately, this does not work, and ends up only showing a file that has the single digit 1 in it.


In reply to Re^8: CGI::Session keeps re-using same session ID by alain_desilets
in thread CGI::Session keeps re-using same session ID by alain_desilets

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.