Lightpanda: the headless browser designed for AI and automation
get rid of file variant in CachedData
Muki Kiboigo94c029ff3226
diff --git a/src/network/HttpClient.zig b/src/network/HttpClient.zigindex 89d020e7b..94777324a 100644--- a/src/network/HttpClient.zig+++ b/src/network/HttpClient.zig@@ -2361,16 +2361,8 @@ pub const Transfer = struct {// Serve a cache entry as this transfer's response. Takes ownership of// `cached` (file-backed bodies are read into the arena and closed).fn bufferCached(self: *Transfer, cached: Cache.CachedResponse) !void {- const arena = self.arena;-const body: []const u8 = switch (cached.data) {.buffer => |b| b,- .file => |f| blk: {- defer f.file.close(lp.io);- const buf = try arena.alloc(u8, f.len);- const n = try f.file.readPositionalAll(lp.io, buf, f.offset);- break :blk buf[0..n];- },};self.setResponseHead(cached.metadata.status, cached.metadata.content_type);diff --git a/src/network/cache/Cache.zig b/src/network/cache/Cache.zigindex c336c406f..49b4003ba 100644--- a/src/network/cache/Cache.zig+++ b/src/network/cache/Cache.zig@@ -219,23 +219,16 @@ pub const RenewResponse = struct {pub const CachedData = union(enum) {buffer: []const u8,- file: struct {- file: std.Io.File,- offset: usize,- len: usize,- },pub fn deinit(self: CachedData) void {switch (self) {.buffer => {},- .file => |*f| f.file.close(lp.io),}}pub fn format(self: CachedData, writer: *std.Io.Writer) !void {switch (self) {.buffer => |buf| try writer.print("buffer({d} bytes)", .{buf.len}),- .file => |f| try writer.print("file(offset={d}, len={d} bytes)", .{ f.offset, f.len }),}}};