Posted on 2005-08-14 08:59:44-07 by book in response to 884
Re: Suggestion for mutator to convert unknown schemes

The hook would be called only if it exists, otherwise the usual 501 response would be sent.

If the hook exists and it returns false, the same old 501 response is sent. If it returns a true value, it is taken to be a URL and process restart a few lines earlier (so if the protocol in the new url is not supported, this sould be catched as well... Mmm, wouldn't that create infinite loops?) OK, scratch that.

If the hook returns a true value, it's taken as a url, and if the protocol is still not supported, the 501 is sent. Otherwise, processing restart a few lines earlier (maybe at the start of the loop).

...

I think there's another way to do what you want. Enable protocol 'proxy' in your proxy's agent, and add a specialised filter for scheme "proxy". That should work, and has the bonus of me not writing a line of code. :-)

# simply accept the 'proxy' scheme $proxy->agent->protocols_allowed( [ @{ $proxy->agent->protocols_allowed }, 'proxy' ] ); # should be pushed very early (first?) $proxy->push_filter( scheme => 'proxy', request => HTTP::Proxy::HeaderFilter::simple->new( sub { my ( $self, $headers, $message) = @_; # ... compute the new $uri ... $message->uri( $uri ); } ), );

This code is untested, but you get the idea.

Direct Responses: 886 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.