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. :-)