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',-path=>'/');
        print "Set-Cookie: $c_whence\n";
        $whither = $a;
        }
   else   {
        $c_whence =
   $cgi->cookie(-name=>'whence',-value=>$a,-expires=>'+1d',-path=>'/');
        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!






Reply via email to