| ... | @@ -962,23 +962,27 @@ fn unpackResource( | ... | @@ -962,23 +962,27 @@ fn unpackResource( |
| 962 | const content_type = req.response.headers.getFirstValue("Content-Type") orelse | 962 | const content_type = req.response.headers.getFirstValue("Content-Type") orelse |
| 963 | return f.fail(f.location_tok, try eb.addString("missing 'Content-Type' header")); | 963 | return f.fail(f.location_tok, try eb.addString("missing 'Content-Type' header")); |
| 964 | | 964 | |
| 965 | if (ascii.eqlIgnoreCase(content_type, "application/x-tar")) | 965 | // Extract the MIME type, ignoring charset and boundary directives |
| | 966 | const mime_type_end = std.mem.indexOf(u8, content_type, ";") orelse content_type.len; |
| | 967 | const mime_type = content_type[0..mime_type_end]; |
| | 968 | |
| | 969 | if (ascii.eqlIgnoreCase(mime_type, "application/x-tar")) |
| 966 | break :ft .tar; | 970 | break :ft .tar; |
| 967 | | 971 | |
| 968 | if (ascii.eqlIgnoreCase(content_type, "application/gzip") or | 972 | if (ascii.eqlIgnoreCase(mime_type, "application/gzip") or |
| 969 | ascii.eqlIgnoreCase(content_type, "application/x-gzip") or | 973 | ascii.eqlIgnoreCase(mime_type, "application/x-gzip") or |
| 970 | ascii.eqlIgnoreCase(content_type, "application/tar+gzip")) | 974 | ascii.eqlIgnoreCase(mime_type, "application/tar+gzip")) |
| 971 | { | 975 | { |
| 972 | break :ft .@"tar.gz"; | 976 | break :ft .@"tar.gz"; |
| 973 | } | 977 | } |
| 974 | | 978 | |
| 975 | if (ascii.eqlIgnoreCase(content_type, "application/x-xz")) | 979 | if (ascii.eqlIgnoreCase(mime_type, "application/x-xz")) |
| 976 | break :ft .@"tar.xz"; | 980 | break :ft .@"tar.xz"; |
| 977 | | 981 | |
| 978 | if (ascii.eqlIgnoreCase(content_type, "application/zstd")) | 982 | if (ascii.eqlIgnoreCase(mime_type, "application/zstd")) |
| 979 | break :ft .@"tar.zst"; | 983 | break :ft .@"tar.zst"; |
| 980 | | 984 | |
| 981 | if (!ascii.eqlIgnoreCase(content_type, "application/octet-stream")) { | 985 | if (!ascii.eqlIgnoreCase(mime_type, "application/octet-stream")) { |
| 982 | return f.fail(f.location_tok, try eb.printString( | 986 | return f.fail(f.location_tok, try eb.printString( |
| 983 | "unrecognized 'Content-Type' header: '{s}'", | 987 | "unrecognized 'Content-Type' header: '{s}'", |
| 984 | .{content_type}, | 988 | .{content_type}, |