mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Package: support gitlab tarball urls
Allows the package manager to download gitlab tarballs from urls such as https://gitlab.com/<namespace>/<project>/-/archive/<sha>/<project>-<sha>.tar.gz Such http requests have headers Content-Type=application/octet-stream and Content-Disposition='attachment; filename="<project>-<sha>.tar.gz"'. The package manager doesn't yet support these headers. This patch doesn't attempt to properly parse the content-disposition header. Instead it checks that it starts with 'attachment;' and ends with '.tar.gz"'.
This commit is contained in:
parent
4ba61a2191
commit
8bbc906b59
1 changed files with 10 additions and 0 deletions
|
|
@ -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});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue