http://www.perlmonks.org?node_id=350285

freak has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: LWP::Simple request through a proxy
by Abigail-II (Bishop) on May 04, 2004 at 12:05 UTC
    Your code isn't doing an LWP::Simple request. It's doing its request through LWP::UserAgent (LWP::Simple will use LWP::UserAgent itself as well). Do one to three things:
    • Forget about LWP::Simple. You seem to cope with LWP::UserAgent fine.
    • Use LWP::Simple, and have it export $ua. Set up the proxy through $au, as in your code (But the method above is just as easy).
    • Either use LWP::UserAgent or LWP::Simple as described above, and setup the proxy using environment variables and a call to $au -> env_proxy.
    Futher note that the second argument of the proxy method must be the proxy you are using - not the site you want to reach via a proxy.

    Abigail

      Step two above is exactly what I wanted but I wasn't quite sure exactly what was required but I am now so for others for future reference:
      # use proxy (comment out if not) my %proxy = ( host => 'http://proxy:8080' ); use LWP::Simple qw(mirror RC_OK RC_NOT_MODIFIED $ua); $ua->proxy(http => "$proxy{host}") if (defined $proxy{host});
      You can see I'm just interested in using mirror.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: LWP::Simple request through a proxy
by dave_the_m (Monsignor) on May 04, 2004 at 11:11 UTC
    Well, the code looks plausible, except that the value in $x should be the URL of the proxy server, while the argument to get() should be the URL of the site you want to get from.
    A reply falls below the community's threshold of quality. You may see it by logging in.