Commit 8bbc906b59
Changed files (1)
src
src/Package.zig
@@ -510,6 +510,16 @@ fn fetchAndUnpack(
// I have not checked what buffer sizes the xz decompression implementation uses
// 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 if (ascii.eqlIgnoreCase(content_type, "application/octet-stream")) {
+ // support gitlab tarball urls such as https://gitlab.com/<namespace>/<project>/-/archive/<sha>/<project>-<sha>.tar.gz
+ // whose content-disposition header is: 'attachment; filename="<project>-<sha>.tar.gz"'
+ const content_disposition = req.response.headers.getFirstValue("Content-Disposition") orelse
+ return report.fail(dep.url_tok, "Missing 'Content-Disposition' header for Content-Type=application/octet-stream", .{});
+ if (mem.startsWith(u8, content_disposition, "attachment;") and
+ mem.endsWith(u8, content_disposition, ".tar.gz\""))
+ {
+ try unpackTarball(gpa, &req, tmp_directory.handle, std.compress.gzip);
+ } else return report.fail(dep.url_tok, "Unsupported 'Content-Disposition' header value: '{s}' for Content-Type=application/octet-stream", .{content_disposition});
} else {
return report.fail(dep.url_tok, "Unsupported 'Content-Type' header value: '{s}'", .{content_type});
}