diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-10-19 22:55:55 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-10-23 13:31:30 +0100 |
commit | 2f3f7b330bf4f06c32bdb101fba8530d90399752 (patch) | |
tree | 74e9f1978de7c9c9d94d752b9da86bfe5512aef2 /dgit | |
parent | 3c607d65d5675be05fb41f87fd74cd3a00016b65 (diff) |
dgit: ftpmaster api fetch: Check http error code (!)
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>
Diffstat (limited to 'dgit')
-rwxr-xr-x | dgit | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -989,7 +989,16 @@ sub api_query ($$) { 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; + 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); } |