On Wed, 12 Sep 2001, Doug MacEachern wrote:
> On Tue, 11 Sep 2001, Stas Bekman wrote:
>
> > Note that the following happens outside the normal modperl build, I just
> > use Apache-Test framework, so it's possible that the problems happen,
> > becase something is not loaded outside of modperl setup.
>
> works fine here. my test was to hack in these changes:
> --- t/response/TestAPI/request_rec.pm 2001/09/08 18:26:46 1.5
> +++ t/response/TestAPI/request_rec.pm 2001/09/12 17:18:14
> @@ -4,12 +4,12 @@
> use warnings FATAL => 'all';
>
> use Apache::Test;
> -
> +use Apache::compat ();
> sub handler {
> my $r = shift;
>
> plan $r, tests => 37;
> -
> + $r->send_http_header('text/html');
> #Apache->request($r); #PerlOptions +GlobalRequest takes care
> my $gr = Apache->request;
>
> i get a header and content-type: text/html as-as and:
> -if i add PerlOptions +ParseHeader (under Location /TestAPI::request_rec)
> -if i change SetHandler to perl-script under the same location
>
> > which for some reason gets cured with:
> > use Apache::Log ();
>
> you should need to do that regardless. it should probably be added to
> Apache::compat though.
>
> > And the final thing, I cannot get print() to work, only $r->print works. I
> > see that quite a few handlers in tests just print, but I cannot figure out
> > what's different in their code that makes plain print() work. I don't seem
> > to be able to override it :(
>
> STDOUT is only tied for you with SetHandler perl-script
>
> > Uh, also what's the different between 'SetHandler perl-script' and
> > 'SetHandler modperl'? I guess the former is for CGI scripts, but couldn't
> > find any docs.
>
> perl-script is like 1.x, sets up tied STDOUT, %ENV, deals with
> PerlOptions +ParseHeaders, etc. SetHandler modperl does nothing but call
> the handler routine.
OK, but it doesn't work outside modperl build. Try this patch:
But don't run the tests, just start the server from Apache-Registry (!)
dir via -start and run: GET http://localhost:8529/cgi-test/simple.pl
the t/basic should do the same.
--- /dev/null Sat Apr 14 19:06:21 2001
+++ Apache-Registry/lib/Apache/Registry.pm Thu Sep 13 02:42:42 2001
@@ -0,0 +1,19 @@
+package Apache::Registry;
+
+use Apache::compat ();
+use Apache::Const -compile => qw(:common);
+use Apache::Log ();
+
+sub handler {
+ $r = shift;
+ $r->send_http_header('text/plain'); # doesn't work!
+ $r->print("Content-type: text/plain\r\n\r\n");
+ print("OK\n");
+
+ 0;#Apache::OK;
+}
+
+
+
+1;
+__END__
--- /dev/null Sat Apr 14 19:06:21 2001
+++ Apache-Registry/Makefile.PL Tue Sep 11 14:44:06 2001
@@ -0,0 +1,24 @@
+require 5.6.1;
+
+use ExtUtils::MakeMaker;
+
+use lib qw(../blib/lib lib );
+
+use Apache::TestMM qw(test clean); #enable 'make test'
+
+# accept the configs from comman line
+Apache::TestMM::filter_args();
+Apache::TestMM::generate_script('t/TEST');
+
+WriteMakefile
+ (
+ NAME => 'Apache::Registry',
+ VERSION_FROM => 'lib/Apache/Registry.pm',
+ clean => {
+ FILES => "@{ clean_files() }",
+ },
+ );
+
+sub clean_files {
+ return [@scripts];
+}
--- /dev/null Sat Apr 14 19:06:21 2001
+++ Apache-Registry/MANIFEST Sat Sep 8 15:00:36 2001
@@ -0,0 +1,5 @@
+lib/Apache/Registry.pm
+t/TEST.PL
+t/basic.t
+Makefile.PL
+MANIFEST
--- /dev/null Sat Apr 14 19:06:21 2001
+++ Apache-Registry/./t/conf/extra.conf.in Thu Sep 13 02:46:16 2001
@@ -0,0 +1,13 @@
+#this file will be Include-d by @ServerRoot@/httpd.conf
+
+Alias /cgi-test/ @ServerRoot@/response/
+
+PerlSwitches -Mlib=@ServerRoot@/../lib
+
+PerlModule Apache::Registry
+<Location /cgi-test>
+ PerlOptions +GlobalRequest
+ SetHandler perl-script
+ PerlResponseHandler "sub { delete $INC{'Apache/Registry.pm'}; require
+Apache::Registry; Apache::Registry::handler(shift);}"
+ PerlOptions +ParseHeaders
+</Location>
--- /dev/null Sat Apr 14 19:06:21 2001
+++ Apache-Registry/t/TEST.PL Sat Sep 8 15:04:20 2001
@@ -0,0 +1,11 @@
+#!perl
+
+use strict;
+use warnings FATAL => 'all';
+
+use lib map { "$_/Apache-Test/lib" } qw(. ..);
+use lib qw(lib);
+
+use Apache::TestRunPerl ();
+
+Apache::TestRunPerl->new->run(@ARGV);
--- /dev/null Sat Apr 14 19:06:21 2001
+++ Apache-Registry/t/basic.t Tue Sep 11 15:07:00 2001
@@ -0,0 +1,21 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Registry;
+use Apache::Test;
+use Apache::TestUtil;
+
+plan tests => 2;
+
+ok 1;
+
+my $config = Apache::TestConfig->thaw;
+my $url = '/cgi-test/simple.pl';
+my $data = $config->http_raw_get($url);
+
+ok t_cmp(
+ "OK",
+ $data,
+ "simple cgi",
+ );
+
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]