You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Daniel Eckstein <de...@it-eckstein.de> on 2007/06/01 12:15:29 UTC
Modify incoming cookie / connection input filter
Dear listmember,
as I am new to the list, so please let me disclaim, that I already
searched the archives, read at perl.apache.org and other documentation,
I am insane and sensible. :)
I am trying to modify incoming http cookie on the fly. The setup is like
user->webserver->bea connector->bea appserver
Iam using Apache 2.0.52, mod_perl 1.99, perl 5.8.5, Redhat AS Server 4.
Primary goal is to modify incoming cookies before they reach the
connector module for bea. It would be even possible to put a additional
reverse proxy before the webserver to accomplish this. Like
user->reverse proxy -> webserver-> bea connector -> bea appserver
The first idea was to modify the cookie using simple a Perlhandler. But
this perlhandler seem to write to the response stream, which is going
back to the client, so the modified cookie never reached the
connector/appserver (which I can see out of its logfile).
Second idea was to use connection input filter to modify the cookie
information right in the incoming apache chain. I managed to setup the
example connection input filter from
http://perl.apache.org/docs/2.0/user/handlers/filters.html#Connection_Input_Filters
It is working, but from my opinion not as expected. I cant see any
header information written to the log, nor do I know, how I should
modify header and write them back into the input chain.
Example output:
------------
data: HTTP/1.1 304 Not Modified
data: Date: Fri, 01 Jun 2007 08:33:55 GMT
data: S
data: S
data: erver: Apache/2.0.58 (Red Hat)
data: C
data: C
data: onnection: close
data:
data:
data:
---------------
Would you please shed some light on this?
Thanks alot in advance!
Rgds,
Daniel
Re: Modify incoming cookie / connection input filter
Posted by Torsten Foertsch <to...@gmx.net>.
On Friday 01 June 2007 12:15, Daniel Eckstein wrote:
> I am trying to modify incoming http cookie on the fly. The setup is like
>
> user->webserver->bea connector->bea appserver
You can certainly do that using a connection input filter. But I'd say that is
much too complicated.
Apache processes requests in several phases, see
http://perl.apache.org/docs/2.0/user/handlers/http.html#HTTP_Request_Cycle_Phases
mod_proxy acts in the response phase. So you can use any of the preceeding
phases to modify the cookie, which is a HTTP header. So you have to modify
$r->headers_in->{Cookie}. I think a PerlFixupHandler would be best for you.
Another way to accomplish the same may be a combination of mod_headers +
mod_rewrite. With mod_rewrite you can set environment variables. With
mod_headers you can modify input and output headers and incorporate the
content of environment variables.
But if you plan to use mod_perl anyway then use it here too.
> Iam using Apache 2.0.52, mod_perl 1.99, perl 5.8.5, Redhat AS Server 4.
Don't do that! This version of mod_perl is beta and is quite old, I think ~3
years. Further, the API has changed in the late beta phase of mp2, see
http://perl.apache.org/docs/2.0/rename.html. So when you'll update your
server later you'll have to rewrite you programs.
Torsten
Re: Modify incoming cookie / connection input filter
Posted by Srebrenko Sehic <ss...@gmail.com>.
On 6/1/07, Daniel Eckstein <de...@it-eckstein.de> wrote:
> Primary goal is to modify incoming cookies before they reach the
> connector module for bea. It would be even possible to put a additional
> reverse proxy before the webserver to accomplish this. Like
>
> user->reverse proxy -> webserver-> bea connector -> bea appserver
You should simply use a PerlPostReadRequestHandler and modify
$r->headers_in directly.
That should do the trick.