Jim Brandt wrote:

On Aug 18, 2005, at 2:03 PM, Stas Bekman wrote:

Jim Brandt wrote:

Got it working! Thanks for the help.
The changes I made are below. Once question:
There's a block that dies if there is no INTERP in the header. This forces you to pass that in the header for all requests made against that version of the server, right?


Why? If you use that feature incorrectly it must die. DECLINED just hides the usage error.


I thought this would handle all requests on that server, so every request would need the extra header. In my case, I might run some tests that use the same interpreter and some that don't. I just didn't want it to die for other test requests against the server.

I might be misunderstanding something or my configuration might be a bit messed up. I've hacked a few things together to get this running in my sanbox set-up. I don't think I have and ideal Apache::Test configuration right now, so maybe I'm getting strange behavior.

You need to put that line:

  PerlInitHandler     Apache::TestHandler::same_interp_fixup

inside the <Location> container, in which case it'll only affect the requests coming to that place.

and please post a unified diff (i.e. using diff -u)


Attached. I gave it a shot and it appears to work with some simple tests on mod_perl 1. I couldn't get it to run with the included tests, but that's because my set-up is a bit strange and I don't have a mod_perl 2 install to test on.


Thanks Jim, but mind to try this version instead? I've polished your patch a bit (see at the end)

I also took a shot at updating sameinterp.pm, but I don't know if that's needed or not.

Well, it'll be useless and confusing to have mp1 code in the mp2 test suite. but if you want to move that test into the Apache-Test suite (where it really belongs) then your patch will be just right on. So please give it a try and send us your findings. Take a look at TestCommon/SameInterp.pm, which is at the moment private to the mp2 test suite. I believe it's ready to be moved into Apache-Test and used by everybody. I guess it could go directly into Apache/TestHandler.pm


Index: lib/Apache/TestHandler.pm
===================================================================
--- lib/Apache/TestHandler.pm   (revision 233548)
+++ lib/Apache/TestHandler.pm   (working copy)
@@ -20,14 +20,25 @@

 use Apache::Test ();
 use Apache::TestRequest ();
+use Apache::TestConfig ();

-use Apache2::Const -compile => qw(OK NOT_FOUND SERVER_ERROR);
+use constant MP2 => Apache::TestConfig::IS_MOD_PERL_2;

+BEGIN {
+    if (MP2) {
+        require Apache2::Const;
+        Apache2::Const->import(-compile => qw(OK NOT_FOUND SERVER_ERROR));
+    }
+    else {
+        require Apache::Constants;
+    }
+}
+
 #some utility handlers for testing hooks other than response
 #see modperl-2.0/t/hooks/TestHooks/authen.pm

-if ($ENV{MOD_PERL} && require mod_perl2) {
-    require Apache2::RequestIO; # puts
+if (MP2) {
+    require Apache2::RequestIO;
 }

 #compat with 1.xx
@@ -87,7 +98,9 @@
     }
     elsif ($interp ne $same_interp_id) {
         # this is not the request interpreter instance
-        return Apache2::Const::NOT_FOUND;
+        return MP2
+            ?    Apache2::Const::NOT_FOUND
+            : Apache::Constants::NOT_FOUND;
     }

     $same_interp_counter++;
@@ -96,7 +109,7 @@
     # value
     $r->headers_out->set(Apache::TestRequest::INTERP_KEY, $id);

-    return Apache2::Const::OK;
+    return MP2 ? Apache2::Const::OK : Apache::Constants::OK;
 }

 1;


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

Reply via email to