perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip M. Gollucci" <pgollu...@p6m7g8.com>
Subject Re: Apache2::Cookie bug, or just my misinterpretation?
Date Fri, 23 Sep 2005 07:22:57 GMT
Foo Ji-Haw wrote:
> I get the request cookie names like this:
> my $jar = Apache2::Cookie::Jar->new($r);
> my @keys = $jar->cookies();
sub fetch {
     my $class = shift;
     my $req = shift;
     unless (defined $req) {
         my $usage = 'Usage: Apache2::Cookie->fetch($r): missing argument $r';
         $req = eval {Apache2::RequestUtil->request} or die <<EOD;
$usage: attempt to fetch global Apache2::RequestUtil->request failed: $@.
EOD
     }
     $req = APR::Request::Apache2->handle($req)
         unless $req->isa("APR::Request");

     my $jar = $req->jar or return;
     $jar->cookie_class(__PACKAGE__);
     return $jar->get(shift) if @_;
     return wantarray ? %$jar : $jar;
}

The reason why is that you do 'wantarray'

You want to instead write:

my $keys_hashref = $jar->cookies();

Also, we don't recommend the Apache2::* interface after/as of 2.05-dev, but 
instead the APR equivalents.

Have a look at
APR::Request::Cookie

You'll notice, its the Apache2::Cookie::fetch() is a wrapper around the APR one 
anyway.


-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com

Mime
View raw message