You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Bram Whillock <br...@cmu.edu> on 2004/04/05 23:07:11 UTC

PerlRun, nothing but page header

I recently built and got up and running apache 1.3.19 with mod_perl and
mod_ssl.  I'm not receiving any error messages, but I cannot get any
output from a test page.

Apache.conf for the directory is as:
PerlWarn On
PerlTaintCheck On
PerlModule Apache::PerlRun

<Directory "/var/www/beta">
        SetHandler perl-script
        PerlHandler Apache::PerlRun
        Options ExecCGI
        allow from all
        PerlSendHeader On
</Directory>

The script I'm trying to run is named modperl.cgi and is as follows:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI;

$CGI = new CGI();
print $CGI->header("text/html");

print STDOUT "<html><body>Hello</body></html>";

However, this produces a 0 length page in the browser.  If I try and get
the page with lwp I get.
[bram@66 bram]$ lwp-request -USex http://66.235.194.176/beta/modperl.cgi
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://66.235.194.176/beta/modperl.cgi
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: OK
GET http://66.235.194.176/beta/modperl.cgi
User-Agent: lwp-request/2.01

GET http://66.235.194.176/beta/modperl.cgi --> 200 OK
Connection: close
Date: Mon, 05 Apr 2004 20:56:39 GMT
Server: Apache/1.3.19 (Unix) mod_perl/1.25 mod_ssl/2.8.1 OpenSSL/0.9.7d
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Mon, 05 Apr 2004 20:56:39 GMT
Client-Response-Num: 1
Client-Transfer-Encoding: chunked

[bram@66 bram]$

I can change the content-type which I'm producing headers for to foobar
and the headers that lwp reports change appropriately, however, I still
get no content returned, and no error messages in the apache error logs
either.  Any ideas?  I am totally confused by this.


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: PerlRun, nothing but page header

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2004-04-05 at 17:45, Bram Whillock wrote:
> I tried changing the PerlHandler to Apache::Registry and modified the
> script so that it does:
> my $r = shift;
> $r->send_http_header("text/plain");
> $r->print("foo");
> return OK;
> 
> Which works fine.  But this isn't a good option considering I've got a
> lot of code that I want to run under PerlRun.

That same script should run under PerlRun without problems.

I notice that your versions of apache and mod_perl are pretty old. 
Maybe your CGI.pm is old too.  You should at least update CGI.pm and
consider updating mod_perl and apache too. 

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: PerlRun, nothing but page header

Posted by Bram Whillock <br...@cmu.edu>.
Yes, my apache.conf reads:
PerlSendHeader On.

> -----Original Message-----
> From: Drew Taylor [mailto:drew@drewtaylor.com]
> Sent: Monday, April 05, 2004 5:56 PM
> To: Bram Whillock
> Cc: 'Modperl List'
> Subject: Re: PerlRun, nothing but page header
> 
> Have you tried setting PerlSendHeader? That will automatically send
the
> headers for you. It's very useful for running under Registry.
> 
>  From Writing Apache Modules, pg 144
> > PerlSendHeader On tells mod_perl to intercept anything that looks
> > like a header line and to automatically turn it into a correctly
>  > formatted HTTP/1.0 header the way that Apache does with CGI
scripts.
> 
> 
> Drew
> 
> Bram Whillock wrote:
> 
> > I tried changing the PerlHandler to Apache::Registry and modified
the
> > script so that it does:
> > my $r = shift;
> > $r->send_http_header("text/plain");
> > $r->print("foo");
> > return OK;
> >
> > Which works fine.  But this isn't a good option considering I've got
a
> > lot of code that I want to run under PerlRun.
> >
> > Also, I removed the shebang line to confirm that it's not using the
> > shebang line to resolve the perl interpreter.
> >
> >
> >>-----Original Message-----
> >>From: Stas Bekman [mailto:stas@stason.org]
> >>Sent: Monday, April 05, 2004 5:38 PM
> >>To: Bram Whillock
> >>Cc: 'Perrin Harkins'; 'Modperl List'
> >>Subject: Re: PerlRun, nothing but page header
> >>
> >>Bram Whillock wrote:
> >>
> >>>Apache error log says:
> >>>mod_perl/1.25
> >>
> >>That means nothing, besides having mod_perl present. You need to
> >
> > configure the
> >
> >>server to run your script under mod_perl.
> >>
> >>Assuming that your script is under:/var/www/beta/modperl.cgi, your
> >>configuration:
> >>
> >>PerlWarn On
> >>PerlTaintCheck On
> >>PerlModule Apache::PerlRun
> >>
> >><Directory "/var/www/beta">
> >>         SetHandler perl-script
> >>         PerlHandler Apache::PerlRun
> >>         Options ExecCGI
> >>         allow from all
> >>         PerlSendHeader On
> >></Directory>
> >>
> >>should work, as long as you don't reset it, somewhere later in
> >
> > httpd.conf.
> >
> >>e.g. with ScriptAlias directive, which will use mod_cgi to run the
> >
> > script.
> >
> >>__________________________________________________________________
> >>Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> >>http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> >>mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> >>http://modperlbook.org http://apache.org   http://ticketmaster.com
> >
> >
> >
> >
> 
> 
> --
> ----------------------------------------------------------------
> Drew Taylor                 *  Web development & consulting
> Email: drew@drewtaylor.com  *  Site implementation & hosting
> Web  : www.drewtaylor.com   *  perl/mod_perl/DBI/mysql/postgres
> ----------------------------------------------------------------
> 



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: PerlRun, nothing but page header

Posted by Drew Taylor <dr...@drewtaylor.com>.
Have you tried setting PerlSendHeader? That will automatically send the 
headers for you. It's very useful for running under Registry.

 From Writing Apache Modules, pg 144
> PerlSendHeader On tells mod_perl to intercept anything that looks
> like a header line and to automatically turn it into a correctly
 > formatted HTTP/1.0 header the way that Apache does with CGI scripts.


Drew

Bram Whillock wrote:

> I tried changing the PerlHandler to Apache::Registry and modified the
> script so that it does:
> my $r = shift;
> $r->send_http_header("text/plain");
> $r->print("foo");
> return OK;
> 
> Which works fine.  But this isn't a good option considering I've got a
> lot of code that I want to run under PerlRun.
> 
> Also, I removed the shebang line to confirm that it's not using the
> shebang line to resolve the perl interpreter.
> 
> 
>>-----Original Message-----
>>From: Stas Bekman [mailto:stas@stason.org]
>>Sent: Monday, April 05, 2004 5:38 PM
>>To: Bram Whillock
>>Cc: 'Perrin Harkins'; 'Modperl List'
>>Subject: Re: PerlRun, nothing but page header
>>
>>Bram Whillock wrote:
>>
>>>Apache error log says:
>>>mod_perl/1.25
>>
>>That means nothing, besides having mod_perl present. You need to
> 
> configure the
> 
>>server to run your script under mod_perl.
>>
>>Assuming that your script is under:/var/www/beta/modperl.cgi, your
>>configuration:
>>
>>PerlWarn On
>>PerlTaintCheck On
>>PerlModule Apache::PerlRun
>>
>><Directory "/var/www/beta">
>>         SetHandler perl-script
>>         PerlHandler Apache::PerlRun
>>         Options ExecCGI
>>         allow from all
>>         PerlSendHeader On
>></Directory>
>>
>>should work, as long as you don't reset it, somewhere later in
> 
> httpd.conf.
> 
>>e.g. with ScriptAlias directive, which will use mod_cgi to run the
> 
> script.
> 
>>__________________________________________________________________
>>Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
>>http://stason.org/     mod_perl Guide ---> http://perl.apache.org
>>mailto:stas@stason.org http://use.perl.org http://apacheweek.com
>>http://modperlbook.org http://apache.org   http://ticketmaster.com
> 
> 
> 
> 


-- 
----------------------------------------------------------------
Drew Taylor                 *  Web development & consulting
Email: drew@drewtaylor.com  *  Site implementation & hosting
Web  : www.drewtaylor.com   *  perl/mod_perl/DBI/mysql/postgres
----------------------------------------------------------------


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: PerlRun, nothing but page header

Posted by Bram Whillock <br...@cmu.edu>.
I tried changing the PerlHandler to Apache::Registry and modified the
script so that it does:
my $r = shift;
$r->send_http_header("text/plain");
$r->print("foo");
return OK;

Which works fine.  But this isn't a good option considering I've got a
lot of code that I want to run under PerlRun.

Also, I removed the shebang line to confirm that it's not using the
shebang line to resolve the perl interpreter.

> -----Original Message-----
> From: Stas Bekman [mailto:stas@stason.org]
> Sent: Monday, April 05, 2004 5:38 PM
> To: Bram Whillock
> Cc: 'Perrin Harkins'; 'Modperl List'
> Subject: Re: PerlRun, nothing but page header
> 
> Bram Whillock wrote:
> > Apache error log says:
> > mod_perl/1.25
> 
> That means nothing, besides having mod_perl present. You need to
configure the
> server to run your script under mod_perl.
> 
> Assuming that your script is under:/var/www/beta/modperl.cgi, your
> configuration:
> 
> PerlWarn On
> PerlTaintCheck On
> PerlModule Apache::PerlRun
> 
> <Directory "/var/www/beta">
>          SetHandler perl-script
>          PerlHandler Apache::PerlRun
>          Options ExecCGI
>          allow from all
>          PerlSendHeader On
> </Directory>
> 
> should work, as long as you don't reset it, somewhere later in
httpd.conf.
> e.g. with ScriptAlias directive, which will use mod_cgi to run the
script.
> 
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: PerlRun, nothing but page header

Posted by Stas Bekman <st...@stason.org>.
Bram Whillock wrote:
> Apache error log says:
> mod_perl/1.25

That means nothing, besides having mod_perl present. You need to configure the 
server to run your script under mod_perl.

Assuming that your script is under:/var/www/beta/modperl.cgi, your configuration:

PerlWarn On
PerlTaintCheck On
PerlModule Apache::PerlRun

<Directory "/var/www/beta">
         SetHandler perl-script
         PerlHandler Apache::PerlRun
         Options ExecCGI
         allow from all
         PerlSendHeader On
</Directory>

should work, as long as you don't reset it, somewhere later in httpd.conf. 
e.g. with ScriptAlias directive, which will use mod_cgi to run the script.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: PerlRun, nothing but page header

Posted by Bram Whillock <br...@cmu.edu>.
Apache error log says:
mod_perl/1.25

> -----Original Message-----
> From: Perrin Harkins [mailto:perrin@elem.com]
> Sent: Monday, April 05, 2004 5:29 PM
> To: Bram Whillock
> Cc: Modperl List
> Subject: RE: PerlRun, nothing but page header
> 
> On Mon, 2004-04-05 at 17:21, Bram Whillock wrote:
> > Getting rid of the fatalsToBrowser does nothing.
> >
> > The second script gives me an error:
> > [Mon Apr  5 14:17:15 2004] [error] PerlRun: `Can't call method
> > "send_http_header" on an undefined value at
/var/www/beta/modperl.cgi
> > line 3.
> 
> Sounds like you aren't running under mod_perl then.  Try printing the
> contents of $ENV{'MOD_PERL'} to STDERR.  If that value is undefined,
> then there's something wrong in your conf file and you are running the
> script as CGI instead.
> 
> - Perrin
> 



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: PerlRun, nothing but page header

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2004-04-05 at 17:21, Bram Whillock wrote:
> Getting rid of the fatalsToBrowser does nothing.
> 
> The second script gives me an error:
> [Mon Apr  5 14:17:15 2004] [error] PerlRun: `Can't call method
> "send_http_header" on an undefined value at /var/www/beta/modperl.cgi
> line 3.

Sounds like you aren't running under mod_perl then.  Try printing the
contents of $ENV{'MOD_PERL'} to STDERR.  If that value is undefined,
then there's something wrong in your conf file and you are running the
script as CGI instead.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: PerlRun, nothing but page header

Posted by Stas Bekman <st...@stason.org>.
Bram Whillock wrote:
> Getting rid of the fatalsToBrowser does nothing.
> 
> The second script gives me an error:
> [Mon Apr  5 14:17:15 2004] [error] PerlRun: `Can't call method
> "send_http_header" on an undefined value at /var/www/beta/modperl.cgi
> line 3.

Meaning that you aren't running that script under modperl, but as mod_cgi. You 
configuration is broken then. To confirm, try:

#!/usr/bin/perl
print "content-type: text/plain\n\n";
print $ENV{MOD_PERL} ? "mod_perl" : "mod_cgi";

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: PerlRun, nothing but page header

Posted by Bram Whillock <br...@cmu.edu>.
Getting rid of the fatalsToBrowser does nothing.

The second script gives me an error:
[Mon Apr  5 14:17:15 2004] [error] PerlRun: `Can't call method
"send_http_header" on an undefined value at /var/www/beta/modperl.cgi
line 3.

> -----Original Message-----
> From: Stas Bekman [mailto:stas@stason.org]
> Sent: Monday, April 05, 2004 5:15 PM
> To: Bram Whillock
> Cc: modperl@perl.apache.org
> Subject: Re: PerlRun, nothing but page header
> 
> Bram Whillock wrote:
> > I recently built and got up and running apache 1.3.19 with mod_perl
and
> > mod_ssl.  I'm not receiving any error messages, but I cannot get any
> > output from a test page.
> 
> Any difference if you remove this line?
> 
>    use CGI::Carp qw(fatalsToBrowser);
> 
> If not, any luck with this script:
> 
> #!/usr/bin/perl
> my $r = shift;
> $r->send_http_header("text/html");
> $r->print("<html><body>Hello</body></html>");
> 
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: PerlRun, nothing but page header

Posted by Stas Bekman <st...@stason.org>.
Bram Whillock wrote:
> I recently built and got up and running apache 1.3.19 with mod_perl and
> mod_ssl.  I'm not receiving any error messages, but I cannot get any
> output from a test page.

Any difference if you remove this line?

   use CGI::Carp qw(fatalsToBrowser);

If not, any luck with this script:

#!/usr/bin/perl
my $r = shift;
$r->send_http_header("text/html");
$r->print("<html><body>Hello</body></html>");

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html