Commit bb16842f authored by Matt Selsky's avatar Matt Selsky Committed by Gervase Markham

Bug 662161: enhance testserver.pl to deal with missing support for HTTPS. r=gerv, a=glob.

parent 2993c6a3
...@@ -26,6 +26,8 @@ my $datadir = bz_locations()->{'datadir'}; ...@@ -26,6 +26,8 @@ my $datadir = bz_locations()->{'datadir'};
eval "require LWP; require LWP::UserAgent;"; eval "require LWP; require LWP::UserAgent;";
my $lwp = $@ ? 0 : 1; my $lwp = $@ ? 0 : 1;
eval "require LWP::Protocol::https;";
my $lwpssl = $@ ? 0 : 1;
if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/i)) if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/i))
{ {
...@@ -212,12 +214,16 @@ sub fetch { ...@@ -212,12 +214,16 @@ sub fetch {
my $url = shift; my $url = shift;
my $rtn; my $rtn;
if ($lwp) { if ($lwp) {
my $req = HTTP::Request->new(GET => $url); if ($url =~ /^https:/i && !$lwpssl) {
my $ua = LWP::UserAgent->new; die("You need LWP::Protocol::https installed to use https with testserver.pl");
my $res = $ua->request($req); } else {
$rtn = ($res->is_success ? $res->content : undef); 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) { } 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 { } else {
my($host, $port, $file) = ('', 80, ''); my($host, $port, $file) = ('', 80, '');
if ($url =~ m#^http://([^:]+):(\d+)(/.*)#i) { if ($url =~ m#^http://([^:]+):(\d+)(/.*)#i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment