2011年5月20日星期五

Re: [PerlChina] LWP::UserAgnet->get(https://...) not work through proxy

And I also have to turn off SSL verify_hostname.

LWP::UserAgent->new(ssl_opts => { verify_hostname => 0});


2011/5/20 Tiger Peng <tigerpeng2001@gmail.com>:
> Thanks for the help.
>
> After replacing strawberry perl 64 bit version with 32 bit version,
> and adding $ENV{https_proxy} = $res->proxy; The script works.
>
> There was warning when I install strawberry perl 64 bit on Windows7
> (64 bit). I just ignored it.
>
> 2011/5/17 cnhack TNT <cnhacktnt@gmail.com>:
>> 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 <tigerpeng2001@gmail.com>
>>>
>>> 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 讨论组"论坛。
>>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
>>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>>>
>>
>> --
>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>>
>

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

没有评论: