+
+ printdebug "archive api query: fetching $url...\n";
+
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $x = $curl->perform();
+ fail f_ "fetch of %s failed (%s): %s",
+ $url, $curl->strerror($x), $curl->errbuf
+ if $x;
+
+ return $curl->getinfo(CURLINFO_HTTP_CODE), $response_body;
+}
+
+sub api_query_raw ($;$) {
+ my ($subpath, $ok404) = @_;
+ my $url = access_cfg('archive-query-url');
+ $url .= $subpath;
+ my ($code,$json) = archive_api_query_curl($url);
+ 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;