perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From will trillich <w...@pinncomp.net>
Subject perlSendHeader On/Off: the difference!
Date Sun, 02 Jul 2000 08:49:07 GMT
perlSendHeader On / Off -- what's the real difference?
i finally figured it out, after seeing many 'server errors'
on one hand, and http headers cluttering up the html output
to the browser on the other...

i have a perl script
	test.npl
and a symbolic link to it
	`ln -s test.npl test.pl`
so that the same code will be called whether it's
*.pl or *.npl...

and in httpd.conf,
   <FilesMatch "\.(pl|perl)">
        Options +ExecCGI
        SetHandler perl-script
        PerlSendHeader On
        PerlHandler Apache::PerlRun
   </FilesMatch>
   <FilesMatch "\.((nph|n)-?)(pl|perl)">
        Options +ExecCGI
        SetHandler perl-script
        PerlSendHeader Off
        PerlHandler Apache::PerlRun
   </FilesMatch>

so any script named *.pl runs with perlSendHeader ON;
any script named *.npl runs with perlSendHeader OFF.

here's the relevant code from the top of the script:

my $eol  = "\015\012";
my $mod  = scalar localtime( $seen{$path} ||= (stat $path)[9] );
my $span = 60*60*24;
print "HTTP/1.1 200 OK",$eol
      if $0 =~ /\.npl$/	# if PERLSENDHEADER == OFF, say 'HTTP/...'
      ;
print "Content-Type: text/html",$eol,
      "Last-Modified: ",$mod,$eol,
      "Date: ",scalar(localtime),$eol,
      "Expires: ",scalar(localtime(time+$span)),$eol,
      $eol
      ;
print "<html>"....

and the script behaves identically, whether called
as *.npl or *.pl, with no server error (missing headers)
and no http clutter at the top of html output (extra
headers).

thus i conclude that (aside from the internals revealed at
http://perl.apache.org/faq/mod_perl_cgi.html#The_script_runs_but_the_headers_
) PERLSENDHEADER ON makes mod_perl generate the initial
'HTTP' intro, and that's that.

yes? no? do i win a prize?

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Their is five errers in this sentance.

Mime
View raw message