chiark / gitweb /
dgit: Use libcurl, not @curl, for git check
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 23 Jul 2019 16:42:08 +0000 (17:42 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 23 Jul 2019 20:58:56 +0000 (21:58 +0100)
This means that when we sort out our TLS problems this will be fixed
too.

The remaining use of command-line curl is just to download additional
.dsc compoments.  I intend to leave that as-is.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index 0f801a3d30127b518b393481e55842bde52a9d20..978eabe84494bb1c01b02689da9fe2ce2345aa53 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1804,22 +1804,11 @@ sub check_for_git () {
        my $suffix = access_cfg('git-check-suffix','git-suffix',
                                'RETURN-UNDEF') // '.git';
        my $url = "$prefix/$package$suffix";
-       my @cmd = (@curl, qw(-sS -I), $url);
-       my $result = cmdoutput @cmd;
-       $result =~ s/^\S+ 200 .*\n\r?\n//;
-       # curl -sS -I with https_proxy prints
-       # HTTP/1.0 200 Connection established
-       $result =~ m/^\S+ (404|200) /s or
-           fail +(__ "unexpected results from git check query - ").
-               Dumper($prefix, $result);
-       my $code = $1;
-       if ($code eq '404') {
-           return 0;
-       } elsif ($code eq '200') {
-           return 1;
-       } else {
-           die;
-       }
+       my $result = url_fetch $url,
+           CurlOpts => { CURLOPT_NOBODY() => 1 },
+           Ok404 => 1,
+           AccessBase => 'git-check';
+       return defined $result;
     } elsif ($how eq 'true') {
        return 1;
     } elsif ($how eq 'false') {