Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

107 views
Skip to first unread message

shal...@gmail.com

unread,
Sep 9, 2008, 6:53:25 AM9/9/08
to
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.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.

C.DeRykus

unread,
Sep 12, 2008, 6:33:13 PM9/12/08
to
On Sep 9, 3:53 am, shall...@gmail.com 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

shal...@gmail.com

unread,
Oct 1, 2008, 3:11:43 AM10/1/08
to
> 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?

0 new messages