Stas Bekman wrote: [...]
the reason I suggested a subclass was so that the rare people who
require nph scripts have an outlet, while the vast majority of users are not
burdened with the overhead of checking for nph- scripts on every request.
A quick index() call to check for "nph-" is not going to matter in any real world scenario.
OK, so it seems that we agree on having the support only for /^nph-/ in registry. Now we just need to decide whether we
1) support this by default for any registry class, unless explicitly overriden in the subclass,
2) or introduce a new subclass just for that purpose.
The problem with (2) is that if you need mix and match nph- and not nph- scripts living in the same dir you will need to duplicate configs.
I'm fine going with (1) since we can always do (2) at a later stage.
so here is the implementation of (1) plus tests.
Index: ModPerl-Registry/lib/ModPerl/RegistryCooker.pm =================================================================== RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm,v retrieving revision 1.40 diff -u -u -r1.40 RegistryCooker.pm --- ModPerl-Registry/lib/ModPerl/RegistryCooker.pm 19 Dec 2003 06:32:28 -0000 1.40 +++ ModPerl-Registry/lib/ModPerl/RegistryCooker.pm 21 Jan 2004 06:38:21 -0000 @@ -25,6 +25,7 @@ use ModPerl::Global ();
use File::Spec::Functions (); +use File::Basename;
use Apache::Const -compile => qw(:common &OPT_EXECCGI);
@@ -360,6 +361,11 @@
$self->strip_end_data_segment;
+ # handle the non-parsed handlers ala mod_cgi (though mod_cgi does + # some tricks removing the header_out and other filters, here we + # just call assbackwards which has the same effect). + my $base = File::Basename::basename($self->{FILENAME}); + my $nph = substr($base, 0, 4) eq 'nph-' ? '$_[0]->assbackwards(1);' : ""; my $script_name = $self->get_script_name || $0;
my $eval = join '', @@ -367,6 +373,7 @@ $self->{PACKAGE}, ";", "sub handler {", "local \$0 = '$script_name';", + $nph, $line, ${ $self->{CODE} }, "\n}"; # last line comment without newline? --- /dev/null 1969-12-31 16:00:00.000000000 -0800 +++ ModPerl-Registry/t/nph.t 2004-01-20 22:29:55.000000000 -0800 @@ -0,0 +1,54 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestUtil; +use Apache::TestRequest; + +plan tests => 6; + +my $url = "/nph/nph-foo.pl"; + +my %expected = ( + code => '250', + body => "non-parsed headers body", + headers => { + 'content-type' => 'text/text', + 'pragma' => 'no-cache', + 'cache-control' => 'must-revalidate, no-cache, no-store', + 'expires' => '-1', + }, +); + +my $res = GET $url; + +my %received = ( + code => $res->code, + body => $res->content, + headers => $res->headers, # LWP lc's the headers +); + +use Data::Dumper; +print Dumper $res->headers; + +for my $key (keys %expected) { + my $expected = $expected{$key}; + my $received = $received{$key}; + if ($key eq 'headers') { + for my $header (keys %$expected) { + ok t_cmp( + $expected->{$header}, + $received->{$header}, + "test header $header" + ); + } + } + else { + ok t_cmp( + $expected, + $received, + "test key: $key" + ); + } +} +
--- /dev/null 1969-12-31 16:00:00.000000000 -0800 +++ ModPerl-Registry/t/cgi-bin/nph-foo.pl 2004-01-20 22:36:55.000000000 -0800 @@ -0,0 +1,13 @@ +#!/usr/bin/perl -w + +my $r = shift; + +print "HTTP/1.0 250 Pretty OK\r\n"; +print join("\n", + 'Content-type: text/text', + 'Pragma: no-cache', + 'Cache-control: must-revalidate, no-cache, no-store', + 'Expires: -1', + "\n"); + +print "non-parsed headers body";
__________________________________________________________________ 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
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]