@@ -79,6 +79,7 @@ sub new {
79
79
try_lwp => 1,
80
80
try_wget => 1,
81
81
try_curl => 1,
82
+ use_http => 0,
82
83
uninstall_shadows => ($] < 5.012),
83
84
skip_installed => 1,
84
85
skip_satisfied => 0,
@@ -199,6 +200,7 @@ sub parse_options {
199
200
' lwp!' => \$self -> {try_lwp },
200
201
' wget!' => \$self -> {try_wget },
201
202
' curl!' => \$self -> {try_curl },
203
+ ' insecure!' => \$self -> {use_http },
202
204
' auto-cleanup=s' => \$self -> {auto_cleanup },
203
205
' man-pages!' => \$self -> {pod2man },
204
206
' scandeps' => \$self -> {scandeps },
@@ -453,7 +455,7 @@ sub search_common {
453
455
$self -> chat(" Found $found ->{module} $found ->{module_version} which doesn't satisfy $want_version .\n " );
454
456
}
455
457
}
456
-
458
+
457
459
return ;
458
460
}
459
461
@@ -977,7 +979,7 @@ sub append_args {
977
979
my ($self , $cmd , $phase ) = @_ ;
978
980
979
981
return $cmd if ref $cmd ne ' ARRAY' ;
980
-
982
+
981
983
if (my $args = $self -> {build_args }{$phase }) {
982
984
$cmd = join ' ' , Menlo::Util::shell_quote(@$cmd ), $args ;
983
985
}
@@ -2657,6 +2659,10 @@ sub mirror {
2657
2659
return $self -> file_mirror($uri , $local );
2658
2660
}
2659
2661
2662
+ # HTTPTinyish does not provide an option to disable
2663
+ # certificates check, let's switch to http on demand.
2664
+ $uri =~ s / ^https:/ http:/ if $self -> {use_http };
2665
+
2660
2666
my $reply = $self -> {http }-> mirror($uri , $local );
2661
2667
2662
2668
if ( $uri =~ / ^https:/ && ref $reply
@@ -2673,7 +2679,8 @@ sub mirror {
2673
2679
die <<"DIE" ;
2674
2680
TLS issue found while fetching $uri :\n
2675
2681
$reply ->{content}\n
2676
- Please verify your certificates or force an HTTP-only request/mirror at your own risk.
2682
+ Please verify your certificates or force an HTTP-only request/mirror
2683
+ using --insecure option at your own risk.
2677
2684
DIE
2678
2685
}
2679
2686
}
@@ -2722,14 +2729,16 @@ sub configure_http {
2722
2729
2723
2730
require HTTP::Tinyish;
2724
2731
2732
+ my $use_http = $self -> {use_http };
2733
+
2725
2734
my @try = qw( HTTPTiny) ;
2726
2735
unshift @try , ' Wget' if $self -> {try_wget };
2727
2736
unshift @try , ' Curl' if $self -> {try_curl };
2728
2737
unshift @try , ' LWP' if $self -> {try_lwp };
2729
2738
2730
- my @protocol = (' https' );
2739
+ my @protocol = ( $use_http ? ' http ' : ' https' );
2731
2740
push @protocol , ' http'
2732
- if grep /^http:/, @{$self -> {mirrors }};
2741
+ if ! $use_http && grep /^http:/, @{$self -> {mirrors }};
2733
2742
2734
2743
my $backend ;
2735
2744
for my $try (map " HTTP::Tinyish::$_ " , @try ) {
@@ -2745,11 +2754,14 @@ sub configure_http {
2745
2754
}
2746
2755
}
2747
2756
2748
- if ( !$backend ) {
2749
- $self -> diag_fail( join ( ' , ' , @protocol )." not supported by available HTTP Clients." );
2750
- }
2757
+ # In case we use https protocol by default
2758
+ # and then later we try to perform non https requests
2759
+ # we still want these requests to succeed
2760
+ # Note: this is disabling the client cache optimization above
2761
+ # and will fail later for SSL requests as no clients support TLS
2762
+ $backend ||= ' HTTP::Tinyish' ;
2751
2763
2752
- $backend -> new(agent => " Menlo/$Menlo::VERSION " , verify_SSL => 1);
2764
+ $backend -> new(agent => " Menlo/$Menlo::VERSION " , $use_http ? () : ( verify_SSL => 1 ) );
2753
2765
}
2754
2766
2755
2767
sub init_tools {
0 commit comments