Takamoto has asked for the wisdom of the Perl Monks concerning the following question:
Hello
I need to run scripts through a proxy on Windows machines. I usually do this:
use strict; use warnings; use LWP::UserAgent; use HTTP::Request; print "Connecting...\n"; my $ua = LWP::UserAgent->new( ); $ua->proxy(['http', 'https'], 'http://127.0.0.1:8888/'); my $url="https://www.google.com"; my $req = HTTP::Request->new(GET => $url); my $response = $ua->request($req); if ($response->is_success) { print "OK CONNECTION!\n"; } else{ print "NO CONNECTION!\n"; }
This works fine. However, I would like to autodetect the proxy. The only thing I found so far is LWP::UserAgent::ProxyAny;. Changing the script to:
use strict; use warnings; use LWP::UserAgent::ProxyAny; use HTTP::Request; print "Connecting...\n"; my $ua = LWP::UserAgent::ProxyAny->new; $ua->env_proxy; my $url="https://www.google.com"; my $req = HTTP::Request->new(GET => $url); my $response = $ua->request($req); if ($response->is_success) { print "OK CONNECTION!\n"; } else{ print "NO CONNECTION!\n"; }
I go through the proxy. If I look inside $ua I found my proxy. HOWEVER, the module is 15 years old, and normally I have lots of doubts in using modules that never get updated. So, before using it in production I would like to have some feedbacks from people using it and know possible problems I could face (and of course I am interested in alternatives, if any). Thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Autodetect Proxy on Windows
by roboticus (Chancellor) on Jan 11, 2019 at 14:13 UTC | |
by stevieb (Canon) on Jan 11, 2019 at 15:13 UTC | |
|
Re: Autodetect Proxy on Windows
by Anonymous Monk on Jan 15, 2019 at 11:38 UTC |