Strange. Maybe Windows deals differently than Unix with reading files that are still open for writing? I'm on Windows.
I'm also on Windows. The code you presented finishes writing to a file, then it streams it.
| [reply] |
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. | [reply] [d/l] |