Server Push Problem
am 19.08.2011 21:15:49 von John M Rathbun MD--------------080400050609000307030202
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hiya!
I've been working on a program that is structured to
1. Do some stuff
2. Send a web page to the client
3. Do some more stuff
4. Send another web page to the client
I read the Server Push instructions in the Perldoc and tried to follow
their directions but the result was not what I was looking for. Instead,
it would
1. Do some stuff
2. Do more stuff
3. Send a web page to the client that combines what should have been on
two separate pages
My program looks something like this:
#!/usr/local/bin/perl
use warnings;
use strict;
use CGI qw/:push -nph/;
$| = 1;
my $cgi=new CGI;
.
.
.
# BEGIN PART ONE
print multipart_init;
# SET COOKIES
if ($whence) {
$c_whence =
$cgi->cookie(-name=>'whence',-value=>"",-expires=>'+1d',-pat h=>'/');
print "Set-Cookie: $c_whence\n";
$whither = $a;
}
else {
$c_whence =
$cgi->cookie(-name=>'whence',-value=>$a,-expires=>'+1d',-pat h=>'/');
print "Set-Cookie: $c_whence\n";
}
print $cgi->header();
print $cgi->start_html ("CLUELESS");
if ($whence) { print "
Starting square is $whence and ending
square is $whither
"; }else { print "
Starting square is $a
"; }.
.
.
print $cgi->end_html();
if ($whence) {
print multipart_end;
sleep 5;
print multipart_start;
print $cgi->header();
print $cgi->start_html ("CLUELESS");
print "
MOVE COMPLETED
";print $cgi->end_html();
}
print multipart_final;
Note that $whence is always true for this part of the program, so I was
intending to see the "Starting square is $whence and ending square is
$whither" message first and then a new page that says MOVE COMPLETED.
The 5" sleep is to simulate the server doing some work between showing
the first and second pages.
When $whence is false, the program produces the expected output. When
$whence is true, I see code like this:
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Starting square is g1 and ending square is f3
.
.
.
Content-Type: text/html; charset=ISO-8859-1
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
MOVE COMPLETED
This leads to the page 1 content followed by the page 2 content instead
of two pages in sequence.
I read that SERVER PUSH is not supported for all browsers. Is this still
true? Is there a workaround you can suggest?
THANKS!
--------------080400050609000307030202--