I am using mod_perl 2 with Apache 2.2.3 on Red Hat 5.2 and I am trying to access request headers, but Apache2 :: RequestRec headers_in (or rather, its return value) does not behave as I expected.
Code snippet:
$logger->warn('version ' . $mod_perl::VERSION);
$logger->warn('r ' . $r);
my $headers = $r->headers_in;
$logger->warn('headers ' . $headers);
my $accept = $headers->get('Accept');
$logger->warn('got $accept');
$logger->warn($accept);
gives the following log output:
WARN version 2.000004
WARN r Apache2::RequestRec=SCALAR(0x2ae0598e9ef0)
WARN headers APR::Table=HASH(0x2ae06cad15a0)
when execution is terminated as soon as any access to APR :: Table is attempted. The related interface for APR :: Table had the same effect, i.e. Changed the line get('Accept')to:
my $accept = $headers->{Accept};
gives exactly the same log output.
According to the above documentation:
This table is available starting at the PerlHeaderParserHandler stage.
Therefore, I expect my code running in the PerlResponseHandler phase to be able to access the headers.
Does anyone have any ideas what I'm doing wrong?
: :: .
:
use Data::Dumper;
$logger->warn(Dumper($r));
my $headers = $r->headers_in;
$logger->warn($headers);
$logger->warn(Dumper($headers));
$logger->warn('have dumped $headers');
:
WARN $VAR1 = bless( do{\(my $o = '47143456365192')}, 'Apache2::RequestRec' );
WARN APR::Table=HASH(0x2ae071b06fd0)
, , $headers Data:: Dumper .
: .
$logger->warn('reset accept');
$r->headers_in->{'Accept'}= 'everything';
$logger->warn('post set accept');
WARN reset accept
. set(Accept => 'everything'), .