diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-11-19 17:08:49 +0000 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-11-20 10:42:21 +0000 |
| commit | b05fefb9c9bf3065e353102d0e54ea76d5f4e34d (patch) | |
| tree | 8648f141532ac235245af263eb4577506f79dda2 /lib/std/http.zig | |
| parent | bc524a2b1a6e5cd13c0093bed240b06d23e1a882 (diff) | |
| download | zig-b05fefb9c9bf3065e353102d0e54ea76d5f4e34d.tar.gz zig-b05fefb9c9bf3065e353102d0e54ea76d5f4e34d.zip | |
std.http: stop assuming previous chunk state
The full file may not be written, either due to a previous chunk being
in-progress when `sendFile` was called, or due to `limit`.
Diffstat (limited to 'lib/std/http.zig')
| -rw-r--r-- | lib/std/http.zig | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/std/http.zig b/lib/std/http.zig index dcc96ba741..eedd729576 100644 --- a/lib/std/http.zig +++ b/lib/std/http.zig @@ -962,6 +962,7 @@ pub const BodyWriter = struct { // have to flush the chunk header before knowing the chunk length. return error.Unimplemented; }; + if (data_len == 0) return error.EndOfStream; const out = bw.http_protocol_output; l: switch (bw.state.chunk_len) { 0 => { @@ -975,8 +976,7 @@ pub const BodyWriter = struct { 2 => { try out.writeAll("\r\n"); bw.state.chunk_len = 0; - assert(file_reader.atEnd()); - return error.EndOfStream; + continue :l 0; }, else => { const chunk_limit: std.Io.Limit = .limited(bw.state.chunk_len - 2); @@ -985,8 +985,7 @@ pub const BodyWriter = struct { else try out.write(chunk_limit.slice(w.buffered())); bw.state.chunk_len -= n; - const ret = w.consume(n); - return ret; + return w.consume(n); }, } } |
