Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re^2: HTTP::Proxy : changing the URI by insaniac
in thread HTTP::Proxy : changing the URI by insaniac

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2021-10-27 04:01 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (91 votes). Check out past polls.