in reply to Re: HTTP::Proxy : changing the URI
in thread HTTP::Proxy : changing the URI

sorry i reply just now... i was pretty tired yesterday evening, so i didn't touch a pc after work ;-)

i showed you a bad example of my code, the working code does use the HTTP::Proxy::HeaderFilter::simple. (otherwise the filter doesn't work; like you also mentioned). i've added the working code to end of this reply.
the $message->$headers->header should have been $message->header (when using HTTP::Proxy::HeaderFilter::simple), and that methods sets or gets a header variable. about the patch: yeah, I thought it was something like that, but is the error really coming from HTTP::Proxy?

anyhow, thanx a bunch for the tips, the patch-tip is probably going to be the most successful one... but i'll keep you posted (btw: we already arranged that the product that's supposed to use this proxy, will use it as a proxy (so it will make "correct" requests). so actually my problem is solved, but I still want to see if this idea would work.. it would be cool, no?)

#!/usr/local/bin/perl -w use strict; use HTTP::Proxy qw/:log/; use HTTP::Headers ; use HTTP::Proxy::HeaderFilter::simple; # Variable init my $host = undef; my $port = 80; my $log_file = "/tmp/proxy.log"; my $localhost = "proxy_host"; my $remotehost = "forwarded_host"; my $agent_timeout = 10; sub search_credentials { my($iv_user,$iv_group) = @_; my($ht_user,$ht_passwd); # test example $ht_user = 'some_web_user'; $ht_passwd = 'passwd'; return ($ht_user,$ht_passwd); } open(LOG,">>", $log_file); my $proxy = HTTP::Proxy->new; $proxy->port($port); $proxy->host($host); $proxy->logfh(*LOG); $proxy->logmask(STATUS | PROCESS | HEADERS | FILTER); # Debug logging my $filter = HTTP::Proxy::HeaderFilter::simple->new( sub { my ( $self, $headers, $message ) = @_; my $get_uri = $message->uri() ? $message->uri() : "http://$rem +otehost/"; if( $get_uri =~ m%^/%) { print "Unaltered URI: $get_uri\n"; $get_uri =~ s?^/?http://$remotehost/? ; print "Altered URI: $get_uri\n"; } my $iv_user = $message->header('iv-user'); my $iv_group = $message->header('iv-group'); my($ht_user,$ht_passwd) = search_credentials($iv_user,$iv_grou +p); $message->authorization_basic($ht_user,$ht_passwd); } ); $proxy->push_filter(request => $filter ); # this is the mainloop $proxy->start;
to ask a question is a moment of shame
to remain ignorant is a lifelong shame