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.

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.

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

Jim

==========================================
Jim Brandt
Administrative Computing Services
University at Buffalo

--- TestHandler.pm.old  Thu Aug 18 13:10:37 2005
+++ TestHandler.pm      Thu Aug 18 15:55:40 2005
@@ -19,14 +19,25 @@
 
 use Apache::Test ();
 use Apache::TestRequest ();
+use mod_perl;
+use constant MP2 => $mod_perl::VERSION < 1.99 ? 0 : 1;
 
-use Apache2::Const -compile => qw(OK NOT_FOUND SERVER_ERROR);
+BEGIN {
+  if (MP2) {
+    require Apache2::Const;
+    Apache2::Const->import(-compile => qw(OK NOT_FOUND SERVER_ERROR));
+  }
+  else {
+    require Apache::Constants;
+    Apache::Constants->import('OK', 'NOT_FOUND', 'SERVER_ERROR');
+  }
+}
 
 #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 ( $ENV{MOD_PERL} && MP2 && require mod_perl2) {
+  require Apache2::RequestIO; # puts
 }
 
 #compat with 1.xx
@@ -86,7 +97,7 @@
     }
     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++;
@@ -95,7 +106,7 @@
     # value
     $r->headers_out->set(Apache::TestRequest::INTERP_KEY, $id);
 
-    return Apache2::Const::OK;
+    return MP2 ? Apache2::Const::OK : Apache::Constants::OK;
 }
 
 1;
--- sameinterp.pm.old   Thu Aug 18 16:05:19 2005
+++ sameinterp.pm       Thu Aug 18 15:23:39 2005
@@ -3,12 +3,24 @@
 use warnings FATAL => 'all';
 use strict;
 
-use Apache2::RequestIO ();
+use mod_perl;
+use constant MP2 => $mod_perl::VERSION < 1.99 ? 0 : 1;
 
 use Apache::TestHandler ();
 
-use Apache2::Const -compile => qw(OK);
+BEGIN {
+  if (MP2) {
+    require Apache2::RequestIO;
+    require Apache2::Const;
+    Apache2::Const->import(-compile => qw(OK));
+  }
+  else {
+    require Apache::Constants;
+    Apache::Constants->import('OK');
+  }
+}
 
+
 my $value = '';
 
 sub handler {
@@ -16,9 +28,9 @@
 
     # test the actual global data
     $value = Apache::TestHandler::same_interp_counter();
-    $r->puts($value);
+    $r->print($value);
 
-    Apache2::Const::OK;
+    return MP2 ? Apache2::Const::OK : Apache::Constants::OK;
 }
 
 1;

Reply via email to