Hello,
I see redirection behaves differently when a message
is printed beforehand then when redirection happens
alone.

Case I ( simple redirection ):
------------------------------
package redirect.pm

use Apache::Const -compile =>
qw(HTTP_MOVED_TEMPORARILY);

sub handler (
   my $r = shift;
   $r->content_type('text/html');
   $r->headers_out->{'Location'}=
"http://new.location";;
   return HTTP_MOVED_TEMPORARILY;
}
1;


Result is : browser immediately loads the new page.

Case II ( Print a message before redirection )
----------------------------------------------
package redirect.pm

use Apache::Const -compile =>
qw(HTTP_MOVED_TEMPORARILY);

sub handler (
   my $r = shift;
   $r->content_type('text/html');
   print "Redirecting to new site ...";
   $r->headers_out->{'Location'}=
"http://new.location";;
   return HTTP_MOVED_TEMPORARILY;
}
1;


Result is : Instead of opening the new URL, the
following is displayed on the browser :
Redirecting to new site ...
Ok
The document has moved here (here is clickable).
...

This is the output of "view page source":

Redirecting to new site ...<!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>200 OK</title>
</head><body>
<h1>OK</h1>
<p>The document has moved <a
href="http://new.location";>here</a>.</p>
<hr />
<address>Apache/2.0.43 Server at myserver.company.com
Port 80</address>
</body></html>


My question is : 
a)What is the reason for this behaviour ? Why does
printing a message halt the redirection ?
b)What needs to be done to display a message saying
"Redirecting .." and then the browser to auto-display
the new URL ?

Thanks in advance ..
Sumitro Chowdhury.


__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

Reply via email to