summaryrefslogtreecommitdiffstats
path: root/testserver.pl
diff options
context:
space:
mode:
authorMatt Selsky <selsky@columbia.edu>2015-01-23 12:11:13 +0100
committerGervase Markham <gerv@gerv.net>2015-01-23 12:11:13 +0100
commitbb16842f9a670da25fdebbcbc4dcdc3ee52cd76f (patch)
tree851fc80fda3b5b44423ca0d067b57620a3f164f2 /testserver.pl
parent2993c6a385fb179ba09377b159384e48486c3f7f (diff)
downloadbugzilla-bb16842f9a670da25fdebbcbc4dcdc3ee52cd76f.tar.gz
bugzilla-bb16842f9a670da25fdebbcbc4dcdc3ee52cd76f.tar.xz
Bug 662161: enhance testserver.pl to deal with missing support for HTTPS. r=gerv, a=glob.
Diffstat (limited to 'testserver.pl')
-rwxr-xr-xtestserver.pl16
1 files changed, 11 insertions, 5 deletions
diff --git a/testserver.pl b/testserver.pl
index d827c80ea..7ee7fe929 100755
--- a/testserver.pl
+++ b/testserver.pl
@@ -26,6 +26,8 @@ my $datadir = bz_locations()->{'datadir'};
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))
{
@@ -212,12 +214,16 @@ sub fetch {
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) {