eval "require LWP; require LWP::UserAgent;";
my $lwp = $@ ? 0 : 1;
+eval "require LWP::Protocol::https;";
+my $lwpssl = $@ ? 0 : 1;
if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/i))
{
my $url = shift;
my $rtn;
if ($lwp) {
- my $req = HTTP::Request->new(GET => $url);
- my $ua = LWP::UserAgent->new;
- my $res = $ua->request($req);
- $rtn = ($res->is_success ? $res->content : undef);
+ if ($url =~ /^https:/i && !$lwpssl) {
+ die("You need LWP::Protocol::https installed to use https with testserver.pl");
+ } else {
+ my $req = HTTP::Request->new(GET => $url);
+ my $ua = LWP::UserAgent->new;
+ my $res = $ua->request($req);
+ $rtn = ($res->is_success ? $res->content : undef);
+ }
} elsif ($url =~ /^https:/i) {
- die("You need LWP installed to use https with testserver.pl");
+ die("You need LWP (and LWP::Protocol::https, for LWP 6.02 or newer) installed to use https with testserver.pl");
} else {
my($host, $port, $file) = ('', 80, '');
if ($url =~ m#^http://([^:]+):(\d+)(/.*)#i) {