in reply to Re: Re: Re: •Re: Chaining proxies with LWP::UserAgent
in thread Chaining proxies with LWP::UserAgent

Having looked at the LWP::UserAgent and LWP::Protocol::HTTP code, I think it should be doable to edit them to add support for the proxy either being an array ref, or a string of proxies chained with some convenient dividers (eg |). The idea is that whever you see a reference to a proxy, you just loop through the proxies and do what you do for all of them. Having scanned it, adding chained proxy support to HTTP looks doable (just a handful of lines in a couple of modules - grep for "proxy" and do "perldoc -l LWP::UserAgent" to find where it is on your system) and probably a lot easier than writing significant new code. It is distributed under the same terms as Perl, those are pretty generous so legal issues are likely not a problem for you.

If don't think your Perl is up to it, ask on the appropriate list and you likely will find someone else who can. (The speed with which they add features for you might be affected by financial encouragement...)

If you then contribute that back, and a lot of people will suddenly be able to easily use chained proxies in Perl if they need it. :-)

PS My comment about chained proxies was not a statement that they aren't useful, just a comment about where I happened to have seen them before.

  • Comment on Re: Re: Re: Re: •Re: Chaining proxies with LWP::UserAgent

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: •Re: Chaining proxies with LWP::UserAgent
by shibboleth (Novice) on Jun 29, 2003 at 06:59 UTC
    Having looked at the LWP::UserAgent and LWP::Protocol::HTTP code, I think it should be doable to edit them to add support for the proxy either being an array ref, or a string of proxies chained with some convenient dividers (eg |).

    If you then contribute that back, and a lot of people will suddenly be able to easily use chained proxies in Perl if they need it. :-)

    Okay, I did it.

    http.pm.diff and UserAgent.pm.diff

    Those patches allow the second argument of the proxy() method to be either an arrayref, or a whitespace-separated list of proxies.

    I sent off the patches to Gisle, hopefully he will accept them in the next version. If so, then proxy chaining via LWP will be available to all! :)

      Way cool. Not sure whether (or when) I would need that, but I know that if I do, it is possible, and I know where to ask. :-)

      Unfortunately you changed the data structure a bit. Someone will have to make equivalent changes to the other protocols. Luckily most of them just check whether there is a and refuse to so they remain the same. And the rest seem to be variations on http so the change should be pretty much the same there.

      Good luck on getting the patch accepted!