Martin Atkins via RT writes:
Show quoted text > <URL:
https://rt.cpan.org/Ticket/Display.html?id=53968 >
>
> On Sun Jan 24 21:14:27 2010, crew@cs.stanford.edu wrote:
> >
> > Also, line 32
> >
> > elsif (ref $what eq "Apache") {
> >
> > is puzzling, since (to my knowledge) there are never any vanilla
> > 'Apache' objects, so I'm not sure how this EVER triggers. If the
> > intent is to cover the case of mod_perl2? servers WITHOUT libapreq2?
> > (is this configuration part of the test suite?), then I believe
> > line 32 needs to be
> >
> > elsif ( ref($what) =~ m/^Apache2?::RequestRec$/) {
ok,... I dug out the mod_perl 1 porting docs and this turns out to be
wrong.
mod_perl 1 *does* indeed bless the request object into 'Apache', and
all of the methods called in the 'Apache' clause (->method, ->content,
->args) are consistent with $what being a mod_perl 1 Apache request
object.
And since both ->content and ->args in list context were eliminated
for mod_perl 2, the clause to deal with mod_perl_2 WITHOUT libapreq2
will need to be totally different...
... and totally insane (see below).
so you probably don't want to change line 32 after all.
I'm also getting the impression it's generally assumed that anyone
using mod_perl 2 also uses libapreq2, since otherwise there's this
nightmare of the Right Way to suck in POST bodies to get at the
parameters. (Presumably, libapreq2 will be merged into Apache Proper
SOME day, but I'm still unclear on why it was ever separate in the
first place.)
Meanwhile, here's what an mod_perl_2-without-libapreq2 clause would
have to look like (note that I have NOT gotten this to work...)
| elsif (ref($what) eq 'Apache2::RequestRec') {
| # EVIL
| # EVIL -- This is ripped straight out of Apache2::compat
| # EVIL
| use constant IOBUFSIZE => 8192;
| require Apache2::Const; # -compile => qw(MODE_READBYTES);
| require APR::Const; # -compile => qw(BLOCK_READ);
| require APR::Brigade;
|
| my $string;
| if ($what->method eq 'POST') {
| my $bb = APR::Brigade->new($what->pool,
| $what->connection->bucket_alloc);
| $string = '';
| my $seen_eos = 0;
| do {
| $what->input_filters->get_brigade($bb, Apache2::Const::MODE_READBYTES,
| APR::Const::BLOCK_READ, IOBUFSIZE);
| while (!$bb->is_empty) {
| my $b = $bb->first;
| if ($b->is_eos) {
| $seen_eos++;
| last;
| }
| if ($b->read(my $buf)) {
| $string .= $buf;
| }
| $b->delete;
| }
| } while (!$seen_eos);
| $bb->destroy;
| }
| else {
| $string = $what->args;
| }
| my %get = ();
| if (defined $string and $string) {
| %get = map {
| tr/+/ /;
| s/%([0-9a-fA-F]{2})/pack("C",hex($1))/ge;
| $_;
| } split /[=&;]/, $string, -1;
| }
| $getter = sub { $get{$_[0]}; };
| $enumer = sub { keys(%get); };
| }