Re: Proxy method does not work using LWP::UserAgent for HTTPS request



On Sep 9, 3:53 am, shall...@xxxxxxxxx wrote:
I have following sample getting file via HTTPS protocal using
LWP::UserAgent module.

#!/usr/bin/perl

use LWP::UserAgent;
use LWP::Debug qw(+);

$uri = $ARGV[0];
$ua = LWP::UserAgent->new;
$ua->timeout(10);
#$ENV{HTTPS_PROXY} = 'myproxy.mydomain:8080'; # (A) this works
$ua->proxy('https', 'myproxy.mydomain:8080'); # (B) this
don't works at all

$response = $ua->get($uri);
if ($response->is_success) {
print $response->decoded_content;}

else {
die $response->status_line;

}

Setting HTTPS_PROXY environment variable works fine, but
use $ua->proxy setting proxy don't work. It gaives following trace.

koroke:~/tmp$ https_get.plhttps://www.somedomain.jp/
LWP::UserAgent::new: ()
LWP::UserAgent::proxy: https myproxy.mydomain:8080
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GEThttps://www.somedomain.jp/
LWP::UserAgent::_need_proxy: Proxied to myproxy.mydomain:8080
LWP::UserAgent::request: Simple response: Not Implemented
501 Protocol scheme '' is not supported at https_get.pl line 17.

Who can explain that's different?
Thanks.

I'm not positive this is correct
but it appears the scheme in
the actual proxy specification is implicit with ENV but not with
the 'ua' method call. So,

$ua->proxy('https', 'myproxy.mydomain:8080');

according to the UserAgent doc examples, should instead read, eg.,

$ua->proxy('https',
'https://.....' );


--
Charles DeRykus
.