[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Rewrite HTTP Headers
- Subject: Rewrite HTTP Headers
- Date: Wed, 23 Apr 2008 12:52:05 +0300
- From: "J Amuse" <suppressed>
I wrote a simple module that parses the HTTP response body and updates
certain text. I want the script to be able to parse and manipulate the
HTTP response headers as well. For example add secure and HttpOnly
flags to certain cookies, or add a redirection when a 500 error code is
returned. The code I have so far is:
======================================================================================
package TE::ST;
# $Header:$
use strict;
use warnings;
use Apache2::Filter ();
use Apache2::RequestRec ();
use APR::Table ();
use Apache2::Const -compile => qw(OK);
use constant BUFF_LEN => 9999;
no warnings qw(redefine);
sub handler {
my $f = shift;
while ($f->read(my $buffer, BUFF_LEN)) {
# Disable autocomplete
$buffer =~ s/login method="post"/login method="post" autocomplete="off" /g;
$f->print($buffer);
}
return Apache2::Const::OK;
}
1;
======================================================================================
when
using f->read it appears as though the HTTP headers are not
including. I know err_headers_out should have access to the headers,
but is there a way to force f->read to access the HTTP headers as
well? I've seen the set and add methods for err_headers_out, but can
someone point me to a code example of either editing the HTTP headers
or rewriting the server response when certain response codes are
received?
Thanks.
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.