chiark / gitweb /
dgit: WWW::Curl Set $response_body to '' explicitly
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 8 Aug 2019 11:30:46 +0000 (12:30 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Aug 2019 23:09:28 +0000 (00:09 +0100)
check_for_git calls url_fetch with a WWW::Curl parameter
CURLOPT_NOBODY which suppresses saving the body.  The result is that
CURLOPT_WRITEDATA does not update $response_body.  Then, even on
success, url_fetch returns undef (which ought to mean 404).

Strictly this is a bit sneaky of check_for_git.  But, rather than
trying to make this interface more formal, just make url_fetch set
$response_body to ''.  It does return this except in the success case,
so the error cases are still handled right.

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

diff --git a/dgit b/dgit
index d24c4e64eb08c2bc08076b85550c458e3be2553b..f7b5025f5717e4565115c2c6023368b9d3f64d3e 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1191,7 +1191,7 @@ sub url_fetch ($;@) {
        confess "$k $v ".$curl->strerror($x)." ?" if $x;
     };
 
        confess "$k $v ".$curl->strerror($x)." ?" if $x;
     };
 
-    my $response_body;
+    my $response_body = '';
     $setopt->(CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS|CURLPROTO_HTTP);
     $setopt->(CURLOPT_URL,             $url);
     $setopt->(CURLOPT_NOSIGNAL,        1);
     $setopt->(CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS|CURLPROTO_HTTP);
     $setopt->(CURLOPT_URL,             $url);
     $setopt->(CURLOPT_NOSIGNAL,        1);