-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Justin,
I try to answer you questions step by step:
1. Why does print "Content-type: text/html\r\n\r\n" work?
Because $r->content_type("text/html") does the same behind the scences
2. Should I use Apache2::RequestUtil->request():
This is only available as of mp-2.0.0 and not mp1.99 so you could not
use it earlier than mp-2.0.0.
3. How can I run scripts under mp1, mp1.99, mp2
- -------------------8<--------------------------
my $MOD_PERL;
if (exists $ENV{MOD_PERL}) {
if (exists $ENV{MOD_PERL_API_VERSION} && $ENV{MOD_PERL_API_VERSION}
== 2) {
$MOD_PERL = 2;
} else {
## maybe there is a %ENV-Var to use but I can not recover how
## it's named
eval "require mod_perl";
if( defined $mod_perl::VERSION ) {
if ($mod_perl::VERSION >= 1.99) {
$MOD_PERL = 1.99;
} else {
$MOD_PERL = 1;
}
}
}
}
my $request;
if( $MOD_PERL == 2 ) {
$request = Apache2::RequestUtil->request();
} elsif( $MOD_PERL == 1.99 ) {
$request = Apache->request();
} else {
$request = Apache->request();
}
- -------------------8<-------------------
The problem you may want to face is that you need a pre-2.0.0
documentation because functions and their arguments may have changed so
maybe need the mp2-mp1.99-mp1-switch also in your code.
Tom
Justin Luster wrote:
> Hi,
>
>
>
> I'm still struggling with trying to understand how Mod_Perl 2 works.
> All I want to do is to have a regular Perl script run under Mod_Perl
> just to speed it up.
>
>
>
> In the past, in Mod_Perl 1 I?ve used this:
>
>
>
> sub PrintHeader
>
> {
>
> if ($ENV{'PERL_SEND_HEADER'})
>
> {
>
> print "Content-type: text/html\r\n\r\n";
>
> }
>
> else
>
> {
>
> my $r = Apache->request;
>
> $r->content_type('text/html');
>
> $r->send_http_header;
>
> }
>
> }
>
>
>
> I then read the documentation where it says:
>
>
>
> Apache->request has been replaced with Apache2::RequestUtil::request( ).
>
>
>
> There is also some other documentation in that section that I don?t
> quite understand. In testing and messing around with this in Mod_Perl 2
> I?ve noticed that the simple
>
>
>
> print "Content-type: text/html\r\n\r\n";
>
>
>
> just works. My Apache configuration looks like this:
>
>
>
> <Directory C:\Apache2\Apache2\htdocs\develop>
>
> Options ExecCGI
>
> AddHandler cgi-script .pl
>
> AddHandler cgi-script .cgi
>
>
>
> #For ModPerl Only
>
> <IfModule mod_perl.c>
>
> <Files ~ (\.pl)>
>
> SetHandler perl-script
>
> PerlResponseHandler ModPerl::Registry
>
> Options ExecCGI
>
> allow from all
>
> PerlOptions +ParseHeaders
>
> </Files>
>
> </IfModule>
>
> </Directory>
>
>
>
> I?m thrilled if:
>
>
>
> print "Content-type: text/html\r\n\r\n";
>
>
>
> just works. But I want to make sure I understand it and that it is OK
> before releasing this.
>
>
>
> I?m just using ModPerl::Registry to speed regular Perl CGI scripts up.
> The code needs to work with regular CGI, Mod_Perl 1, Mod_Perl 1.99, and
> Mod_Perl 2.
>
>
>
> And by the way $ENV{'PERL_SEND_HEADER'} does not seem to exist any
> more. Is this not available in Mod_Perl 2?
>
> How do detect:
>
>
>
> PerlOptions -ParseHeaders?
>
>
>
> Thanks for your help,
>
>
>
> Justin
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org
iD8DBQFDKSKokVPeOFLgZFIRAi8sAKCoW1s2Ds2kWYvrMDQWlu5pdekYYACeOBa4
tN0ebd2NBiGX2KJ7UEQa8Jc=
=jUT+
-----END PGP SIGNATURE-----