You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Pringle, Chris (HP-PSG)" <ch...@hp.com> on 2003/09/18 12:27:28 UTC
[mp2][QUESTION]: Filter to modify request headers on a proxy server
Hi,
I am trying to write a filter that will sit on a proxy server and alter
HTTP requests. Basically, what I want it to do is modify the User-Agent
header field so that when the request is proxied, the remote web server
gets a different User-Agent header field to the one that was originally
sent by the browser. There are also other header fields I may need to
modify, but I would imagine this is a simple task once I've worked out
how to alter the User-Agent field.
Does anyone have any ideas how I might go about doing this? I've tried
writing several PerlInputFilterHandlers, all with no success. Will input
filters work with a proxy? I've got output filters working with no
problem.
Any sample code to do what I want, along with the relavent Apache
directives would be very much appreciated!
******** _/ ***********************************************
***** _/ ****** Chris Pringle **
**** _/ ***** **
*** _/_/_/ _/_/_/ ***** Personal Systems Group (PSG) **
*** _/ _/ _/ _/ ***** Hewlett Packard - Bristol **
*** _/ _/ _/_/_/ ***** **
**** _/ INVENT ****** Tel - +44 (0) 117 31 29664 **
****** _/ ******** Email - chris.pringle@hp.com **
******* _/ *************************************************
Re: [mp2][QUESTION]: Filter to modify request headers on a proxy
server
Posted by Stas Bekman <st...@stason.org>.
Pringle, Chris (HP-PSG) wrote:
> Hi,
>
> I am trying to write a filter that will sit on a proxy server and alter
> HTTP requests. Basically, what I want it to do is modify the User-Agent
> header field so that when the request is proxied, the remote web server
> gets a different User-Agent header field to the one that was originally
> sent by the browser. There are also other header fields I may need to
> modify, but I would imagine this is a simple task once I've worked out
> how to alter the User-Agent field.
>
> Does anyone have any ideas how I might go about doing this? I've tried
> writing several PerlInputFilterHandlers, all with no success. Will input
> filters work with a proxy? I've got output filters working with no
> problem.
>
> Any sample code to do what I want, along with the relavent Apache
> directives would be very much appreciated!
The sample code that you need is here:
http://perl.apache.org/docs/2.0/user/handlers/filters.html#Connection_Input_Filters
I haven't tried to mix filters with proxy, but I see no reason why shouldn't
it work. It might not work if proxy is implemented as a filter itself and is
running before the modperl filters, need to look at the actual implementation.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com