Commit 87de8212ad
Changed files (1)
src
src/Package.zig
@@ -489,8 +489,15 @@ fn fetchAndUnpack(
try req.start();
try req.wait();
+ if (req.response.status != .ok) {
+ return report.fail(dep.url_tok, "Expected response status '200 OK' got '{} {s}'", .{
+ @enumToInt(req.response.status),
+ req.response.status.phrase() orelse "",
+ });
+ }
+
const content_type = req.response.headers.getFirstValue("Content-Type") orelse
- return report.fail(dep.url_tok, "missing Content-Type for '{s}'", .{uri.path});
+ return report.fail(dep.url_tok, "Missing 'Content-Type' header", .{});
if (ascii.eqlIgnoreCase(content_type, "application/gzip") or
ascii.eqlIgnoreCase(content_type, "application/x-gzip") or
@@ -504,7 +511,7 @@ fn fetchAndUnpack(
// by default, so the same logic applies for buffering the reader as for gzip.
try unpackTarball(gpa, &req, tmp_directory.handle, std.compress.xz);
} else {
- return report.fail(dep.url_tok, "unknown file extension for path '{s}'", .{uri.path});
+ return report.fail(dep.url_tok, "Unsupported 'Content-Type' header value: '{s}'", .{content_type});
}
// TODO: delete files not included in the package prior to computing the package hash.