HTTP headers

[prev] [thread] [next] [Date index for 2005/03/20]

From: Octavian Rasnita
Subject: HTTP headers
Date: 07:52 on 20 Mar 2005
Hi,

I have tried the following script under Windows 2000, mod_perl 2, Perl
5.8.4:

use strict;
use CGI;

my $q = new CGI;

print "Content-type: text/html\n\nTestare\n";
$q->redirect("http://localhost/";);

This should print the Content-type: text/html header, then the word
"testare" in the body, then the word "Location: http://localhost/";, but it
doesn't happen this way.

The page is redirected to http://localhost/ and after the redirection
header, "Content-type: text/html" followed by "testare" are still printed.

I think this may have something to do with the fact that CGI.pm is loaded
before anything by mod_perl, and who knows why, the method $q->redirect() is
used before other print statements.

Please tell me how can I avoid this, and print the headers in order?

Thank you.

PS. I have seen that if I use print "Location: http://localhost/\n\n";
instead of using the CGI method, it doesn't happen what I said.

Teddy

HTTP headers
Octavian Rasnita 07:52 on 20 Mar 2005

Re: HTTP headers
David Dick 07:56 on 20 Mar 2005

Re: HTTP headers
Tuomo Salo 13:14 on 21 Mar 2005

Generated at 15:10 on 27 Mar 2005 by mariachi v0.52