Skip to content

Commit 8427602

Browse files
Merge pull request #413 from karlseguin/mime
Improve performance & compliance of MIME parsing
2 parents c78b582 + 4ab02fa commit 8427602

File tree

4 files changed

+361
-120
lines changed

4 files changed

+361
-120
lines changed

src/browser/browser.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const Types = @import("root").Types;
2424
const parser = @import("netsurf");
2525
const Loader = @import("loader.zig").Loader;
2626
const Dump = @import("dump.zig");
27-
const Mime = @import("mime.zig");
27+
const Mime = @import("mime.zig").Mime;
2828

2929
const jsruntime = @import("jsruntime");
3030
const Loop = jsruntime.Loop;
@@ -375,8 +375,10 @@ pub const Page = struct {
375375
defer alloc.free(ct.?);
376376

377377
log.debug("header content-type: {s}", .{ct.?});
378-
const mime = try Mime.parse(ct.?);
379-
if (mime.eql(Mime.HTML)) {
378+
var mime = try Mime.parse(alloc, ct.?);
379+
defer mime.deinit();
380+
381+
if (mime.isHTML()) {
380382
try self.loadHTMLDoc(req.reader(), mime.charset orelse "utf-8", auxData);
381383
} else {
382384
log.info("non-HTML document: {s}", .{ct.?});

0 commit comments

Comments
 (0)