diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig index 8447c4e03e..693247e730 100644 --- a/lib/std/http/Server.zig +++ b/lib/std/http/Server.zig @@ -693,9 +693,11 @@ pub const Response = struct { switch (res.transfer_encoding) { .chunked => { - try res.connection.writer().print("{x}\r\n", .{bytes.len}); - try res.connection.writeAll(bytes); - try res.connection.writeAll("\r\n"); + if (bytes.len > 0) { + try res.connection.writer().print("{x}\r\n", .{bytes.len}); + try res.connection.writeAll(bytes); + try res.connection.writeAll("\r\n"); + } return bytes.len; },