http.BodyWriter: handle EOF in chunkedSendFile, simplify

With these changes, the `zig std` command now works again and doesn't
trigger assertion failures or mess up the chunked transfer encoding.
This commit is contained in:
Isaac Freund
2025-08-16 13:11:19 +02:00
parent ce4e8a991f
commit 0cfd07bc86
3 changed files with 56 additions and 115 deletions

View File

@@ -448,11 +448,11 @@ pub const Request = struct {
try out.writeAll("\r\n");
const elide_body = request.head.method == .HEAD;
const state: http.BodyWriter.State = if (o.transfer_encoding) |te| switch (te) {
.chunked => .{ .chunked = .init },
.chunked => .init_chunked,
.none => .none,
} else if (options.content_length) |len| .{
.content_length = len,
} else .{ .chunked = .init };
} else .init_chunked;
return if (elide_body) .{
.http_protocol_output = request.server.out,
@@ -478,7 +478,7 @@ pub const Request = struct {
.drain = http.BodyWriter.contentLengthDrain,
.sendFile = http.BodyWriter.contentLengthSendFile,
},
.chunked => &.{
.chunk_len => &.{
.drain = http.BodyWriter.chunkedDrain,
.sendFile = http.BodyWriter.chunkedSendFile,
},