#!/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.pl https://www.somedomain.jp/
LWP::UserAgent::new: ()
LWP::UserAgent::proxy: https myproxy.mydomain:8080
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://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
Thanks for your great hint. Your advise works for HTTP,
$ua->proxy('http', 'http://myproxy.mydomain:8080/');
...This is good for HTTP URLs, but for HTTPS URLs, both of following
failed.
$ua->proxy('https', 'https://myproxy.mydomain:8080/');
...this gives "500 SSL negotiation failed" after a long hang up.
$ua->proxy('https', 'http://myproxy.mydomain:8080/');
...this gives "400 Bad Request".
Any ideas?