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

I like to connect to a website over a proxy, using the LWP::UserAgent. So I write this little script

#!/usr/bin/perl -w use LWP::UserAgent; #Tried this notation $ENV{HTTPS_PROXY} = 'http://115.238.164.208:8080'; my $ua = LWP::UserAgent->new(); #Also tried this notation #$ua->env_proxy( ); #$ua->proxy(['https'], 'http://115.238.164.208:8080'); my $req = HTTP::Request->new(GET => 'http://google.de'); my $res = $ua->request($req); if($res->is_success) { print "Proxy works fine\n"; #print $res->decoded_content; } else { print "Proxy dont work\n"; }

The Problem I have is that I can change the Proxy IP Adress to something silly like http://blabla.com and it work too. Did I do something wrong? If not is there a way to tell the UserAgent only go over the proxy

Replies are listed 'Best First'.
Re: Issue with LWP:UserAgent use Proxy
by Corion (Patriarch) on May 06, 2014 at 11:58 UTC

    You instruct your $ua to use the proxy for https. But your URL is http :-)

      I change the Line

      my $req = HTTP::Request->new(GET =>'http://google.de');

      to

      my $req = HTTPS::Request->new(GET=>'https://google.de');

      but it is still the same...

        unlikely story :)
        #!/usr/bin/perl -- use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new; $ua->show_progress( 1 ); $ua->proxy( [ qw{ http https } ] => q{http://127.6.6.6} ); $ua->get( q{http://example.com} ); __END__ ** GET http://example.com ==> 500 Can't connect to 127.6.6.6:80 (10061 +) (2s)