stas 2004/01/24 17:04:16
Modified: ModPerl-Registry/lib/ModPerl RegistryCooker.pm
. Changes
Added: ModPerl-Registry/t nph.t
ModPerl-Registry/t/cgi-bin nph-foo.pl
Log:
ModPerl::Registry and friends now support non-parsed headers scripts,
whose filename =~ /^nph-/, identically to mod_cgi
Revision Changes Path
1.41 +7 -0 modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm
Index: RegistryCooker.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -u -r1.40 -r1.41
--- RegistryCooker.pm 19 Dec 2003 06:32:28 -0000 1.40
+++ RegistryCooker.pm 25 Jan 2004 01:04:16 -0000 1.41
@@ -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?
1.1 modperl-2.0/ModPerl-Registry/t/nph.t
Index: nph.t
===================================================================
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
);
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"
);
}
}
1.1 modperl-2.0/ModPerl-Registry/t/cgi-bin/nph-foo.pl
Index: nph-foo.pl
===================================================================
#!/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";
1.310 +3 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.309
retrieving revision 1.310
diff -u -u -r1.309 -r1.310
--- Changes 23 Jan 2004 15:27:08 -0000 1.309
+++ Changes 25 Jan 2004 01:04:16 -0000 1.310
@@ -12,6 +12,9 @@
=item 1.99_13-dev
+ModPerl::Registry and friends now support non-parsed headers scripts,
+whose filename =~ /^nph-/, identically to mod_cgi. + test [Stas]
+
expose APR::Brigade::length() and APR::Brigade::flatten()
[Geoffrey Young]