#1: Server Push Problem
Posted on 2011-08-19 21:15:49 by 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 "<h1>Starting square is $whence and ending
square is $whither</h1>"; }
else { print "<h1>Starting square is $a</h1>"; }
.
.
.
print $cgi->end_html();
if ($whence) {
print multipart_end;
sleep 5;
print multipart_start;
print $cgi->header();
print $cgi->start_html ("CLUELESS");
print "<h1>MOVE COMPLETED</h1>";
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:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"lang="en-US"xml:lang="en-US">
<head>
<title>CLUELESS</title>
<meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"/>
</head>
<body>
<h1>Starting square is g1 and ending square is f3</h1>
.
.
.
</body>
</html>Content-Type: text/html; charset=ISO-8859-1
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"lang="en-US"xml:lang="en-US">
<head>
<title>CLUELESS</title>
<meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"/>
</head>
<body>
<h1>MOVE COMPLETED</h1>
</body>
</html>
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--
Report this message |
#2: Re: Server Push Problem
Posted on 2011-08-19 21:31:01 by Jim Gibson
On 8/19/11 Fri Aug 19, 2011 12:15 PM, "John M Rathbun"
<jmrathbun@bellsouth.net> scribbled:
> 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:
>
[snipped]
>
> 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?
Please read this. It is a little dated (2002), but hopefully still relevant
to your problem:
<http://www.stonehenge.com/merlyn/LinuxMag/col39.html>
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Report this message |