Skip to content

Lightpanda: the headless browser designed for AI and automation

add application/octet-stream to Mime

Muki Kiboigodcbf1e0a8d48
diff --git a/src/browser/Mime.zig b/src/browser/Mime.zig
index d2e10fbca..5ada17003 100644
--- a/src/browser/Mime.zig
+++ b/src/browser/Mime.zig
@@ -47,6 +47,7 @@ pub const ContentTypeEnum = enum {
image_png,
image_webp,
application_json,
+ application_octet_stream,
unknown,
other,
other_xml,
@@ -65,6 +66,7 @@ pub const ContentType = union(ContentTypeEnum) {
image_png: void,
image_webp: void,
application_json: void,
+ application_octet_stream: void,
unknown: void,
// A valid but unrecognized type/subtype. Keeping it would require some
// memory management of the input. Nothing needs it right now, so why bother.
@@ -86,6 +88,7 @@ pub fn contentTypeString(mime: *const Mime) []const u8 {
.image_gif => "image/gif",
.image_webp => "image/webp",
.application_json => "application/json",
+ .application_octet_stream => "application/octet-stream",
else => "",
};
}
@@ -451,6 +454,7 @@ fn parseContentType(value: []const u8) !struct { ContentType, usize } {
@"image/webp",
@"application/json",
+ @"application/octet-stream",
@"application/xml",
}, type_name)) |known_type| {
const ct: ContentType = switch (known_type) {
@@ -467,6 +471,7 @@ fn parseContentType(value: []const u8) !struct { ContentType, usize } {
.@"image/gif" => .{ .image_gif = {} },
.@"image/webp" => .{ .image_webp = {} },
.@"application/json" => .{ .application_json = {} },
+ .@"application/octet-stream" => .{ .application_octet_stream = {} },
};
return .{ ct, attribute_start };
}
@@ -898,6 +903,8 @@ test "Mime: parse common" {
try expect(.{ .content_type = .{ .image_png = {} } }, "image/png");
try expect(.{ .content_type = .{ .image_gif = {} } }, "image/gif");
try expect(.{ .content_type = .{ .image_webp = {} } }, "image/webp");
+
+ try expect(.{ .content_type = .{ .application_octet_stream = {} } }, "application/octet-stream");
}
test "Mime: parse uncommon" {