You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2004/01/22 00:58:52 UTC

[mp2] the vhost/basic patch update

This is just an update on the patch that I've sent long time ago, since the 
older patch won't work with the current cvs. It's just the tests, so it most 
likely fails just as before on win32.

--- /dev/null	1969-12-31 16:00:00.000000000 -0800
+++ t/vhost/basic.t	2004-01-21 15:51:20.000000000 -0800
@@ -0,0 +1,33 @@
+# the handler is configured in modperl_extra.pl via
+# Apache->server->add_config
+
+use Apache::TestUtil;
+use Apache::TestRequest 'GET';
+
+my $config = Apache::Test::config();
+my $vars = $config->{vars};
+
+my $module = 'TestVhost::basic';
+my $path = Apache::TestRequest::module2path($module);
+
+Apache::TestRequest::module($module);
+my $hostport = Apache::TestRequest::hostport($config);
+
+t_debug("connecting to $hostport");
+my $res = GET "http://$hostport/$path";
+
+if ($res->is_success) {
+    print $res->content;
+}
+else {
+    if ($res->code == 404) {
+        my $docroot = $vars->{documentroot};
+        die "this test gets its <Location> configuration added via " .
+            "$documentroot/vhost/startup.pl, this could be the cause " .
+            "of the failure";
+    }
+    else {
+        die "server side has failed (response code: ", $res->code, "),\n",
+            "see t/logs/error_log for more details\n";
+    }
+}

--- /dev/null	1969-12-31 16:00:00.000000000 -0800
+++ t/response/TestVhost/basic.pm	2004-01-21 15:51:28.000000000 -0800
@@ -0,0 +1,59 @@
+package TestVhost::basic;
+
+# Test whether vhost with 'PerlOptions +Parent', which doesn't inherit
+# from the base, has its own INC and therefore can have a modules with
+# the same namespace as the base, but different content.
+#
+# Also see the parallel TestDirective::perlmodule handler
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache::RequestUtil ();
+use APR::Table ();
+
+use File::Spec::Functions qw(catdir);
+
+use Apache::Const -compile => 'OK';
+
+sub handler {
+    my $r = shift;
+
+    plan $r, tests => 1;
+
+    {
+        my $expected = $r->document_root;
+        my $received = $r->dir_config->get('DocumentRootCheck');
+        ok t_cmp($expected, $received, "DocumentRoot");
+    }
+
+    Apache::OK;
+}
+
+1;
+__END__
+<NoAutoConfig>
+<VirtualHost TestVhost::basic>
+    DocumentRoot @documentroot@/vhost
+
+    <IfDefine PERL_USEITHREADS>
+        # a new interpreter pool
+        PerlOptions +Parent
+    </IfDefine>
+
+    # use test system's @INC
+    PerlSwitches -I@serverroot@
+
+    # mp2 modules
+    PerlRequire "@serverroot@/conf/modperl_inc.pl"
+
+    # private to this vhost stuff
+    PerlRequire "@documentroot@/vhost/startup.pl"
+
+    # <Location /TestVhost__basic> container is added via add_config
+    # in t/htdocs/vhost/startup.pl
+</VirtualHost>
+</NoAutoConfig>

--- /dev/null	1969-12-31 16:00:00.000000000 -0800
+++ t/htdocs/vhost/startup.pl	2004-01-21 15:44:34.000000000 -0800
@@ -0,0 +1,32 @@
+use warnings;
+use strict;
+
+use Apache2;
+use Apache::ServerUtil ();
+use Apache::Server ();
+
+use File::Spec::Functions qw(catdir);
+
+# base server
+my $s = Apache->server;
+
+my $vhost_doc_root = catdir Apache::Server::server_root, qw(htdocs vhost);
+
+# testing $s->add_config() in vhost
+my $conf = <<"EOC";
+# must use PerlModule here to check for segfaults
+# (even though it's not required)
+PerlModule TestVhost::basic
+PerlSetVar DocumentRootCheck $vhost_doc_root
+<Location /TestVhost__basic>
+    SetHandler modperl
+    PerlResponseHandler TestVhost::basic
+</Location>
+EOC
+
+$s->add_config([split /\n/, $conf]);
+
+# this used to have problems on win32
+$s->add_config(['<Perl >', '1;', '</Perl>']);
+
+1;


__________________________________________________________________
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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org