mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-28 23:50:05 +00:00
cdp: add mimeType and charset to Network.Response
This commit is contained in:
@@ -22,6 +22,7 @@ const Allocator = std.mem.Allocator;
|
||||
const CdpStorage = @import("storage.zig");
|
||||
const Transfer = @import("../../http/Client.zig").Transfer;
|
||||
const Notification = @import("../../notification.zig").Notification;
|
||||
const Mime = @import("../../browser/mime.zig").Mime;
|
||||
|
||||
pub fn processMessage(cmd: anytype) !void {
|
||||
const action = std.meta.stringToEnum(enum {
|
||||
@@ -392,6 +393,20 @@ const TransferAsResponseWriter = struct {
|
||||
try jws.write(@as(std.http.Status, @enumFromInt(status)).phrase() orelse "Unknown");
|
||||
}
|
||||
|
||||
{
|
||||
const mime: Mime = blk: {
|
||||
if (transfer.response_header.?.contentType()) |ct| {
|
||||
break :blk try Mime.parse(ct);
|
||||
}
|
||||
break :blk .unknown;
|
||||
};
|
||||
|
||||
try jws.objectField("mimeType");
|
||||
try jws.write(mime.contentTypeString());
|
||||
try jws.objectField("charset");
|
||||
try jws.write(mime.charsetString()[0..]);
|
||||
}
|
||||
|
||||
{
|
||||
// chromedp doesn't like having duplicate header names. It's pretty
|
||||
// common to get these from a server (e.g. for Cache-Control), but
|
||||
|
||||
Reference in New Issue
Block a user