Subject: | Use with fake Apache::ConfigFile AND with FCGI::Spawn |
Hello Jorg,
I found it pretty to use Apache::Fake as a begin for an emulation of
mod_perl in my module, FCGI::Spawn.
I'd like to have the Apache::Fake features without Apache::ConfigFile
functionality at all. Thus I created an empty fake package
Apache::ConfigFile on FCGI::Spawn::ModPerl like this:
===
package Apache::ConfigFile;
use strict;
use warnings;
BEGIN{
$INC{ 'Apache/ConfigFile.pm' } = $INC{ 'FCGI/Spawn/ModPerl.pm' };
}
1;
===
but I still can not initialize the Apache's request object as
Apache::Fake->new without this patch:
===
--- Fake.pm.orig
+++ Fake.pm
@@ -1126,8 +1126,6 @@ sub new
# connection
$conf{'ABORTED'} = 0;
- $conf{'FD_IN'} = fileno(STDIN);
- $conf{'FD_OUT'} = fileno(STDOUT);
# remote ident
$conf{'REMOTE_IDENT'} = $conf{'ENV'}{'REMOTE_IDENT'};
@@ -1265,25 +1263,11 @@ sub new
die ($@) if $@;
}
- die 'no PerlHandler found, but we have: '.join(keys %$handlers)
unless exists $$handlers{'PerlHandler'};
-
- my $eval_string = $$handlers{'PerlHandler'};
- if ($eval_string =~ m/->/) {
- $eval_string .= '($r)';
- } elsif ($eval_string =~ m/^[a-zA-Z_0-9:]+$/) {
- $eval_string .= '::handler($r)';
- } elsif ($eval_string !~ m/[{&]/) {
- die "unknown handler syntax: $eval_string";
- }
%ENV = %{$conf{'ENV'}};
#$r->warn("invoking: $eval_string");
- my $rc = eval($eval_string);
die ($@) if $@;
- #$r->warn("rc = $rc");
- $r->status($rc) if $rc;
- $r->send_http_header;
return $r;
}
===
I need this for headers*, *notes, and many other functions. Also, I need
no header to be sent at the request initialization moment.
I can copy the whole new() thing to my module but it sounds too long for
me. Besides the need to track changes on your module to keep my mod_perl
emulation up to date, I'm not much experienced in the whole mod_perl
thing to know exactly what is certainly needed for applications of
FCGI-Spawn kind ( CGI-like ) in the case they will need any of the
mod_perl features.
There are some other things on the source code: I redefine several
packages those are found in the Apache::Fake originally AND add some
packages for mod_perl2 emulation:
http://gitweb.vereshagin.org/FCGI-Spawn/blob/HEAD:/FCGI-Spawn/Spawn/ModPerl.pm
Mo opportunity is: to split the constructor method into the part that
depends on real ConfigFile and the independent. As you may see, my patch
removes some lines of the code and this is a hint on what to encapsulate
separately about.
Thank you!