| ... | ... | @@ -5,6 +5,7 @@ const std = @import("std"); |
| 5 | 5 | const fs = std.fs; |
| 6 | 6 | const mem = std.mem; |
| 7 | 7 | const Allocator = mem.Allocator; |
| 8 | const ascii = std.ascii; |
| 8 | 9 | const assert = std.debug.assert; |
| 9 | 10 | const log = std.log.scoped(.package); |
| 10 | 11 | const main = @import("main.zig"); |
| ... | ... | @@ -488,11 +489,16 @@ fn fetchAndUnpack( |
| 488 | 489 | try req.start(); |
| 489 | 490 | try req.wait(); |
| 490 | 491 | |
| 491 | | if (mem.endsWith(u8, uri.path, ".tar.gz")) { |
| 492 | const content_type = req.response.headers.getFirstValue("Content-Type") orelse |
| 493 | return report.fail(dep.url_tok, "missing Content-Type for '{s}'", .{uri.path}); |
| 494 | |
| 495 | if (ascii.eqlIgnoreCase(content_type, "application/gzip") or |
| 496 | ascii.eqlIgnoreCase(content_type, "application/x-gzip")) |
| 497 | { |
| 492 | 498 | // I observed the gzip stream to read 1 byte at a time, so I am using a |
| 493 | 499 | // buffered reader on the front of it. |
| 494 | 500 | try unpackTarball(gpa, &req, tmp_directory.handle, std.compress.gzip); |
| 495 | | } else if (mem.endsWith(u8, uri.path, ".tar.xz")) { |
| 501 | } else if (ascii.eqlIgnoreCase(content_type, "application/x-xz")) { |
| 496 | 502 | // I have not checked what buffer sizes the xz decompression implementation uses |
| 497 | 503 | // by default, so the same logic applies for buffering the reader as for gzip. |
| 498 | 504 | try unpackTarball(gpa, &req, tmp_directory.handle, std.compress.xz); |