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

LWP::Protocol::https patches

Thread Previous
From:
Chris Hiner
Date:
April 19, 2001 09:29
Subject:
LWP::Protocol::https patches
Message ID:
20010419122942.A18533@quark.didntduck.org
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 http://proxy.example.com:port    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;
#LWP::Debug::level('+');
 
my $ua = LWP::UserAgent->new;
 
my $url=shift || 'https://www.verisign.com';

# 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
Crypt-SSLeay-0.25
libwww-perl-5.53  (with no patches)
openssl-0.9.5a 

Hopefully this helps someone else.

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

Chris
chiner@didntduck.org

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About