On Wed, 23 Feb 2005 18:04:42 -0800, Ofer Nave <[EMAIL PROTECTED]> wrote:
> > hey
> > when i run a script that i have made that the output should be in HTML
> > so that it is a webpage, mod_perl
> > runs because i can see the output but this is then not wrote as HTML
> > rather as plain text.
> > i have sent the Content-Type: text/html and this is show aswell as the
> > compleate HTML code.
> First, I'm not sure if headers are case sensitive or not (8 years of web
> dev and somehow it never came up), but you might want to try changed
> "Content-type" to "Content-Type"

Case does not matter (atleast not on apache). CONTENT-type,
Content-type and Content-Type all work.

> > eg.
> > my script shows links but instead of showing a HTML link it shows <a
> > href="somewhere.pl">this link</a>
> > and not the link.
> > this first few lines of the output screen i have shown...............
> > START OF OUPUT
> > HTTP/1.1 200 OK
> > Date: Thu, 24 Feb 2005 01:33:47 GMT
> > Content-type: text/html
> > <html>
> > <head>
> > END OF OUTPUT
> Second, make sure you have an empty line between your headers and the
> start of your html document.

This is correct. You should have 2 carriage returns after your header.
If you are using CGI, you could do this by using a print statement:

print "Content-type: text/html\n\n";  #notice the 2 '\n'.

You can also use the CGI class:

my $cgi = new CGI;

print $cgi->header('text/html');

The CGI class will format a correct header for you with carriage
returns and all.

You can also use the Apache::Request since you are running mod_perl.

my $r = shift;
$r->send_http_header("text/html"); 

> > i have found "PerlSendHeaders On" in my apache conf file is this
> > anything to do with it???

The apache documentation states:

When this directive is set to ``on'', it forces mod_perl to search for
script output that looks like an HTTP header and automatically calls
the API function send_http_header(). Turning it off saves a few CPU
cycles.

Personally, I have had some problems with PerlSendHeader set to on. In
some weird cases, the header is incorrectly formed. This usually
resulted in the problem that you are experiencing. The inconsistent
behaviour coupled with the overhead of searching for a header makes it
not worth it for me. And if you're running mod_perl, you should really
take advantage of the API it has. You can do alot of manipulation of
the headers.

Hope this helps,

Rick Apichairuk

Reply via email to