[BUG?] CGI::Cookie-parse() deletes $r-content()
I'm looking to see if anyone can verify whether the following behavior is a Feature or a Bug. From within a PerlRequestHandler: my $content = $r-content(); my $cookie = CGI::Cookie-parse( $r-headers_in-get('Cookie') ); works fine, but the reversed code: my $cookie = CGI::Cookie-parse( $r-headers_in-get('Cookie') ); my $content = $r-content(); ... sets $content to undef. I'm aware you can only call $r-content() once; but it seems odd that Cookie-parse would squish it too.(?) Note that this code: my $cookie = $r-headers_in-get('Cookie'); my $content = $r-content(); my $cookie_parsed = CGI::Cookie-parse( $cookie ); ... is OK, implying it's the -parse() that's undef'ing $content, not the call to headers_in(). -- using (Apache/1.3.19 (Unix) mod_perl/1.25 Perl5.6.0 CGI::Cookie/1.12) undef Red Hat i686-linux: -- the behavior doesn't happen on similarly configured older system, (Apache/1.3.12 mod_perl/1.24 Perl5.005_03 CGI::Cookie/1.06)) Anyone else see this / can verify? MikeL
CGI::Cookie parse
Hi! I'm trying to write an AccessHandler. I'm using CGI::Cookie to, you got it, create and parse Cookies. However, I'm getting an error that I don't totally understand. ( This is mod_perl related... just hold on. ) If i call CGI::Cookie-parse($r-headers_in-get('Cookie')); I will get this error: Can't call method "register_cleanup" on an undefined value at /usr/lib/perl5/5.00503/CGI.pm line 262. Now that is on this line in the CGI.pm constructor: if ($MOD_PERL) { ---Apache-request-register_cleanup(\CGI::_reset_globals); undef $NPH; } Why does that fail? I'm running under mod_perl.. I mean this is failing when it is called from a PerlAccessHandler! My second question is why does CGI::Cookie create CGI object just to get a url! The call to CGI::new is becuase of this call in CGI::Cookie-new(): # IE requires the path and domain to be present for some reason. $path = CGI::url(-absolute=1) unless defined $path; # $path = "/" unless defined $path; removing the call to CGI::url fixes the error. So.. any advice or explanation? Aaron
Re: CGI::Cookie parse
use Apache; use Apache::Cookie; sub handler { my $r = shift; my $cookies = Apache::Cookie-new($r)-parse; my %bar = $cookies-{foo}-value; } much simpler, no? On Fri, 4 Feb 2000, Aaron Ross wrote: Hi! I'm trying to write an AccessHandler. I'm using CGI::Cookie to, you got it, create and parse Cookies. However, I'm getting an error that I don't totally understand. ( This is mod_perl related... just hold on. ) If i call CGI::Cookie-parse($r-headers_in-get('Cookie')); I will get this error: Can't call method "register_cleanup" on an undefined value at /usr/lib/perl5/5.00503/CGI.pm line 262. Now that is on this line in the CGI.pm constructor: if ($MOD_PERL) { ---Apache-request-register_cleanup(\CGI::_reset_globals); undef $NPH; } Why does that fail? I'm running under mod_perl.. I mean this is failing when it is called from a PerlAccessHandler! My second question is why does CGI::Cookie create CGI object just to get a url! The call to CGI::new is becuase of this call in CGI::Cookie-new(): # IE requires the path and domain to be present for some reason. $path = CGI::url(-absolute=1) unless defined $path; # $path = "/" unless defined $path; removing the call to CGI::url fixes the error. So.. any advice or explanation? Aaron - nick
Re: CGI::Cookie parse
On Fri, 4 Feb 2000, Aaron Ross wrote: Hi! I'm trying to write an AccessHandler. I'm using CGI::Cookie to, you got it, create and parse Cookies. However, I'm getting an error that I don't totally understand. ( This is mod_perl related... just hold on. ) If i call CGI::Cookie-parse($r-headers_in-get('Cookie')); I will get this error: Can't call method "register_cleanup" on an undefined value at /usr/lib/perl5/5.00503/CGI.pm line 262. Now that is on this line in the CGI.pm constructor: if ($MOD_PERL) { ---Apache-request-register_cleanup(\CGI::_reset_globals); undef $NPH; } Why does that fail? I'm running under mod_perl.. I mean this is failing when it is called from a PerlAccessHandler! The solution is to add to Ihttpd.conf: PerlPostReadRequestHandler 'sub { Apache-request(shift) }' ___ Stas Bekmanmailto:[EMAIL PROTECTED] http://www.stason.org/stas Perl,CGI,Apache,Linux,Web,Java,PC http://www.stason.org/stas/TULARC perl.apache.orgmodperl.sourcegarden.org perlmonth.comperl.org single o- + single o-+ = singlesheavenhttp://www.singlesheaven.com
Re: CGI::Cookie parse
Thanks for your help! I'll look at Apache::Cookie, too. Although I don't really see the big difference in simplicity. Aaron On Fri, 4 Feb 2000, Aaron Ross wrote: Hi! I'm trying to write an AccessHandler. I'm using CGI::Cookie to, you got it, create and parse Cookies. However, I'm getting an error that I don't totally understand. ( This is mod_perl related... just hold on. ) If i call CGI::Cookie-parse($r-headers_in-get('Cookie')); I will get this error: Can't call method "register_cleanup" on an undefined value at /usr/lib/perl5/5.00503/CGI.pm line 262. Now that is on this line in the CGI.pm constructor: if ($MOD_PERL) { ---Apache-request-register_cleanup(\CGI::_reset_globals); undef $NPH; } Why does that fail? I'm running under mod_perl.. I mean this is failing when it is called from a PerlAccessHandler! The solution is to add to Ihttpd.conf: PerlPostReadRequestHandler 'sub { Apache-request(shift) }' ___ Stas Bekmanmailto:[EMAIL PROTECTED] http://www.stason.org/stas Perl,CGI,Apache,Linux,Web,Java,PC http://www.stason.org/stas/TULARC perl.apache.orgmodperl.sourcegarden.org perlmonth.comperl.org single o- + single o-+ = singlesheavenhttp://www.singlesheaven.com