You should try HTTP::ProxyPAC if you want proxy auto configuration: use strict; use LWP::UserAgent; use Data::Dumper; use HTTP::ProxyPAC;
my $ua=LWP::UserAgent->new(); my $pacFile = 'http://corppac.myclient.com/accelerated_pac_base.pac'; my $pac = HTTP::ProxyPAC->new($pacFile); my $res = $pac->find_proxy($url); $ua->proxy(['https', 'http'] => $res->proxy) if $res->proxy; my $response = $ua->get(' https://login.yahoo.com/config/login_verify2?&.src=ym'); print Dumper $response; Make sure you have IO::Socket::SSL or Net::SSL installed for HTTPS support, IO::Socket::SSL is recommended. 2011/5/17 tiger <[email protected]> > Could anyone help on the following test script (run on strawberry > perl)? > > It works (with $ua->proxy... commented out) when it is not behind > proxy, but fails to access https pagethrough proxy (with '_msg' => > 'Bad Request'.). It is okay to access http pages. No problem for > accessing https pages with MSIE and Firfox through proxy. > > Thanks, > > > use strict; > use LWP::UserAgent; > use Data::Dumper; > > my $ua=LWP::UserAgent->new(); > $ua->proxy(['https', 'http'] => 'http://corppac.myclient.com/ > accelerated_pac_base.pac'); > my $response = $ua->get('https://login.yahoo.com/config/login_verify2? > &.src=ym'); > #my $response = $ua->get('http://www.yahoo.com'); > print Dumper $response; > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > > -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
