develooper Front page | perl.libwww | Postings from April 2001

LWP::Protocol::https patches

Thread Previous
Chris Hiner
April 19, 2001 09:29
LWP::Protocol::https patches
Message ID:
Finally we're really close to having https support work via proxy without
needing any patches at all.  There is only one little bug to workaround,
and once that is fixed, there won't be any surprises when trying to use
https and proxies.

Since Crypt::SSLeay supports proxies itself since .19, the LWP::UserAgent code
needs to not read the https_proxy environment variable in env_proxy().
Right now, if you call env_proxy and let it load the https_proxy, it'll try
to send a GET https://host/ to the proxy server, which only works
on some proxy servers.

Crypt::SSLeay expects an environment variable https_proxy with a
value of    without a trailing /.
(LWP doesn't care about trailing /'s in its proxy settings)

Here's my test code with a workaround for the env var:
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $url=shift || '';

# Note: this only works with lower case https_proxy env.  If yours is upper,
# this'll break unless you make these upper case.
my $https_proxy=$ENV{https_proxy};
delete $ENV{https_proxy} if($https_proxy);
$ua->env_proxy;  # Load proxy settings (but not the https proxy)
$ENV{https_proxy}=$https_proxy if($https_proxy);
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
print $res->as_string;

I've also tested POST and HEAD, and they seem to work fine also.

Here's my current config:
Redhat 6.2
perl 5.6.0
libwww-perl-5.53  (with no patches)

Hopefully this helps someone else.

Thanks to all the people that have worked to make this less painful than it
used to be.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About