1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Some cosmetics and simplifies.

This commit is contained in:
Guenter Knauf 2014-10-23 16:27:40 +02:00
parent 2be6941f42
commit 4b7d499e64

View File

@ -234,18 +234,17 @@ sub sha1 {
sub oldsha1 { sub oldsha1 {
my ($crt)=@_; my $sha1 = "";
my $sha1=""; open(C, "<$_[0]") || return 0;
open(C, "<$crt") || return 0; while(<C>) {
while(<C>) { chomp;
chomp; if($_ =~ /^\#\# SHA1: (.*)/) {
if($_ =~ /^\#\# SHA1: (.*)/) { $sha1 = $1;
$sha1 = $1; last;
last;
}
} }
close(C); }
return $sha1; close(C);
return $sha1;
} }
if ( $opt_p !~ m/:/ ) { if ( $opt_p !~ m/:/ ) {
@ -277,31 +276,23 @@ my $stdout = $crt eq '-';
my $resp; my $resp;
my $fetched; my $fetched;
my $oldsha1= oldsha1($crt); my $oldsha1 = oldsha1($crt);
print STDERR "SHA1 of old file: $oldsha1\n" if (!$opt_q); print STDERR "SHA1 of old file: $oldsha1\n" if (!$opt_q);
print STDERR "Downloading '$txt' ...\n" if (!$opt_q); print STDERR "Downloading '$txt' ...\n" if (!$opt_q);
if($curl && !$opt_n) { if($curl && !$opt_n) {
my $https = $url; my $https = $url;
$https =~ s/^http:/https:/; $https =~ s/^http:/https:/;
printf "Get certdata over HTTPS with curl!\n", $https; print STDERR "Get certdata over HTTPS with curl!\n" if (!$opt_q);
my $quiet = $opt_q?"-s":""; my $quiet = $opt_q ? "-s" : "";
my @out = `curl -w %{response_code} $quiet -O $https`; my @out = `curl -w %{response_code} $quiet -O $https`;
if(@out && $out[0] == 200) {
my $code = 0; $fetched = 1;
if(@out) { } else {
$code = $out[0]; print STDERR "Failed downloading HTTPS with curl, trying HTTP with LWP\n" if (!$opt_q);
} }
if($code == 200) {
$fetched = 1;
}
else {
print STDERR "Failed downloading HTTPS with curl, trying HTTP with LWP\n"
unless $opt_q;
}
} }
unless ($fetched || ($opt_n and -e $txt)) { unless ($fetched || ($opt_n and -e $txt)) {