summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2019-07-23 15:18:22 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2019-07-23 15:18:22 +0100
commit9949ffa8a74cd5441b9566acabb935bc18d291da (patch)
tree1bc45759023423c0ac96836134a87090f8044ebe
parent9988391d38561dfa83372cb4a1ba881bbe60d727 (diff)
dgit: Break out api_query_raw
In support of #932570. No functional change. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-xdgit11
1 files changed, 9 insertions, 2 deletions
diff --git a/dgit b/dgit
index cde8546..80adf1f 100755
--- a/dgit
+++ b/dgit
@@ -1223,8 +1223,7 @@ sub archive_api_query_cmd ($) {
return @cmd;
}
-sub api_query ($$;$) {
- use JSON;
+sub api_query_raw ($$;$) {
my ($data, $subpath, $ok404) = @_;
badcfg __ "ftpmasterapi archive query method takes no data part"
if length $data;
@@ -1240,6 +1239,14 @@ sub api_query ($$;$) {
return undef if $code eq '404' && $ok404;
fail f_ "fetch of %s gave HTTP code %s", $url, $code
unless $url =~ m#^file://# or $code =~ m/^2/;
+ return $json;
+}
+
+sub api_query ($$;$) {
+ my ($data, $subpath, $ok404) = @_;
+ use JSON;
+ my $json = api_query_raw $data, $subpath, $ok404;
+ return undef unless defined $json;
return decode_json($json);
}