You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Benjamin Reed <ra...@befunk.com> on 2000/04/29 08:02:35 UTC

PerlSendHeader

I've turned off PerlSendHeader, but no matter what I do, it seems that I'm
already getting headers before I ever print anything.

I have the following in my httpd.conf:

---(snip!)---
Alias /perl/ /home/httpd/perl/
<Location /perl>
 SetHandler perl-script
 PerlHandler Apache::Registry
 PerlSendHeader Off
 Options Indexes ExecCGI
</Location>
---(snip!)---

If I have a script called /home/httpd/perl/index.pl with only the following:

---(snip!)---
$|++;
print <<END;
Content-type: text/html

Hi.
END
---(snip!)---

I end up with "Content-type: text/html Hi." in the browser.

Is there something else I need to do to keep apache from sending headers?
Could it be that some other module is making the headers for me?  (All the
docs I've found on the perl.apache.org site haven't said much more than
"turn PerlSendHeader Off", so if there's a FM that I need to R, I'll happily
get out of your hair ;)

I'm using Apache 1.3.9 with mod_perl 1.23 and perl 5.005_03 on Red Hat
Linux.

Thanks in advance for any assistance...

---
Ben Reed a.k.a. Ranger Rick
ranger@befunk.com
http://defiance.dyndns.org/


Re: PerlSendHeader

Posted by "Frank D. Cringle" <fd...@cliwe.ping.de>.
"Benjamin Reed" <ra...@befunk.com> writes:
> I've turned off PerlSendHeader, but no matter what I do, it seems that I'm
> already getting headers before I ever print anything.

If you turn PerlSendHeader off, you are responsible for sending the
headers yourself.  In the Apache API, and mod_perl's incarnation of
it, sending the headers is achieved by calling $r->send_http_header,
after having set the header values using calls such as
$r->content_type("text/html").  Read 'perldoc Apache' to see all the
stuff that you can put into the headers in this way.

With PerlSendHeader on, mod_perl emulates mod_cgi by slurping up the
initial non-blank lines from your output and doing the above for you,
behind the scenes.

> I have the following in my httpd.conf:
> 
> ---(snip!)---
> Alias /perl/ /home/httpd/perl/
> <Location /perl>
>  SetHandler perl-script
>  PerlHandler Apache::Registry
>  PerlSendHeader Off
>  Options Indexes ExecCGI
> </Location>
> ---(snip!)---
> 
> If I have a script called /home/httpd/perl/index.pl with only the following:
> 
> ---(snip!)---
> $|++;
> print <<END;
> Content-type: text/html
> 
> Hi.
> END
> ---(snip!)---

That should be

use Apache;
my $r = Apache::Request;
$r->content_type('text/html');
$r->send_http_header;
$r->print('Hi.');


-- 
Frank Cringle,      fdc@cliwe.ping.de
voice: (+49 2304) 467101; fax: 943357