We are going to want to handle 404 specially so do not just use -f.
Handle file:/// specially since curl just always invents 000 for the
http error code in that case.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit (2.6~) unstable; urgency=medium
dgit (2.6~) unstable; urgency=medium
+ * Check for non-2xx HTTP status codes from ftpmaster api server.
* Always honour --curl= and --curl:.
--
* Always honour --curl= and --curl:.
--
badcfg "ftpmasterapi archive query method takes no data part"
if length $data;
my @cmd = archive_api_query_cmd($subpath);
badcfg "ftpmasterapi archive query method takes no data part"
if length $data;
my @cmd = archive_api_query_cmd($subpath);
+ my $url = $cmd[$#cmd];
+ push @cmd, qw(-w %{http_code});
my $json = cmdoutput @cmd;
my $json = cmdoutput @cmd;
+ unless ($json =~ s/\d+\d+\d$//) {
+ failedcmd_report_cmd undef, @cmd;
+ fail "curl failed to print 3-digit HTTP code";
+ }
+ my $code = $&;
+ fail "fetch of $url gave HTTP code $code"
+ unless $url =~ m#^file://# or $code =~ m/^2/;
return decode_json($json);
}
return decode_json($json);
}