HTTP-Proxy - Re: Changing the request hostname in GET and POST

Posted on Tue Aug 16 21:31:54 2005 by book in response to 898 (See the whole thread of 3)
Re: Changing the request hostname in GET and POST

I do not understand your explanations, but I can answer your question anyway. :-)

HTTP::Proxy has two types of filters: HeaderFilter and BodyFilter. Those can be set up (with the push_filter() method) to act either on the request or the response. Most requests (with the notable exception of POST requests) do not have bodies, so if you want to change something in a request, it's usually the headers (or the query itself). For this, you'll need to use a subclass of HTTP::Proxy::HeaderFilter. The filter() method has the following signature:

my ( $self, $headers, $message ) = @_;

Where $message is a HTTP::Request (or a HTTP::Response) object. So, to change the request on the fly, you just need to set $message->uri to whatever you want.

Also note that you do not have to write a full subclass: most of my filters are written using HTTP::Proxy::HeaderFilter::simple (or HTTP::Proxy::BodyFilter::simple)

Check out http://http-proxy.mongueurs.net/ for CVS snapshot and mailing list for HTTP::Proxy

Direct Responses: 900 | Write a response