diff --git a/src/Package.zig b/src/Package.zig index f4593fee484413d56959fdcd3e82b6cdd08aad20..f84f0a8a1b6681d8c6d7d0737b4e15248defab71 100644 --- a/src/Package.zig +++ b/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///-/archive//-.tar.gz + // whose content-disposition header is: 'attachment; filename="-.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}); }