perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Allgood" <>
Subject trying to add header field using PerlInputFilterHandler to proxy packets
Date Tue, 30 Jun 2009 02:07:15 GMT
I am running an apache server 2.2.3 on CentOS 5.2.  I have turned on the
proxy with the following lines from my apache.conf:
<IfModule mod_proxy.c>
ProxyRequests On
<Proxy *>
    Order deny,allow
    Deny from all
    Allow from all
I would like to add a header field to all requests going through the
proxy.  After doing a bunch of reading it seemed that setting up a
PerlInputFilterHandler was the right thing to do.  I added the following
lines to the apache.conf
PerlModule company::AddHeader
PerlInputFilterHandler company::AddHeader 
and I wrote the following example handler
package company::AddHeader;
use strict;
use warnings;
use Apache2::Filter ();
use Apache2::RequestRec ();
use APR::Table ();
use Apache2::Const -compile => qw(OK DECLINED);
my $debug = 1;
sub handler {
  my $f = shift;
  # if we have already seen this do nothing
  return Apache2::Const::DECLINED if $f->ctx;
  # get headers
  my $headers_in = $f->r->headers_in();
  # add header field
  $headers_in->set("Message","Hi Mom");
    open FILE, ">>/tmp/out.log" or die $!;
    foreach my $key (keys %{$headers_in})
      print FILE "$key = $headers_in->{$key}\n";
    close FILE;
  return Apache2::Const::OK;

As you can see, if debugging is turned on the headers are written to the
file /tmp/out.log.  The contents of out.log contains the new header, but
the requests being forwarded by the proxy don't seem to be altered.  Why
is the new header not being sent?
I am pretty sure I am missing something very simple, but have spent a
day trying to figure out what it is.  Any ideas?

View raw message