You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Andrew O'Brien <an...@oriel.com.au> on 2007/07/16 23:51:41 UTC

Patch to 2.2.0 Embperl.pm to fix cookie header handling under mod_perl 2

Hi all,

I'm surprised this hasn't come up for anyone else but there is a problem
with line 355 of Embperl.pm when it attempts to get the request cookie
headers using $req_rec->header_in(), namely header_in() doesn't exist in
mod_perl 2 :) (See:
http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_heade
r_in_)

Simple patch below. The APR::Table is an extra "require" call as
headers_in() returns an APR::Table object and the hash isn't accessible
in a tied manner unless that module is loaded.

I haven't tested this under earlier mod_perl versions - you may need a
similar "require Apache::Table ;" in the appropriate stanza for those.

--- Embperl.pm.orig	2006-04-09 00:55:14.000000000 +1000
+++ Embperl.pm	2007-07-16 18:38:26.000000000 +1000
@@ -74,6 +74,7 @@
         require Apache2::ServerRec ;
         require Apache2::ServerUtil ;
         require Apache2::RequestRec ;
+        require APR::Table ; # for Apache2::RequestRec->headers_in()
         require Apache2::RequestUtil ;
         require Apache2::SubRequest ;
         $srv_rec = Apache2::ServerUtil -> server ;
@@ -352,7 +353,7 @@
     my $debug = $appparam?$appparam -> {debug} &
Embperl::Constant::dbgSession:0 ;
     if (!$uid)
         {
-        my $cookie_val  = $ENV{HTTP_COOKIE} ||
($req_rec?$req_rec->header_in('Cookie'):undef) ;
+        my $cookie_val  = $ENV{HTTP_COOKIE} ||
($req_rec?$req_rec->headers_in->{'Cookie'}:undef) ;
 
 	if ((defined ($cookie_val) && ($cookie_val =~
/$cookie_name=(.*?)(\;|\s|$)/)) || ($ENV{QUERY_STRING} =~
/$cookie_name=.*?:(.*?)(\;|\s|&|$)/) || $ENV{EMBPERL_UID} )
 	    {



-- 
Andrew O'Brien

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org