authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-07 18:03:55-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-07 19:55:40-07:00
log6244f5c6cbd87c364be6a54ebfe40d1e6f581532
treed306dc95e3cbaba27bcc03bb6c00d967e5ae5ee2
parentaf2ac24333a7de1abecc784cc1bc7e2ef005c873

std.http.bodyReader: add missing flush in endUnflushed

It's a bit counter-intuitive, but there are two streams here: the implementation here, and the connected output stream. When we say "unflushed" we mean don't flush the connected output stream because that's managed externally. But an "end" operation should always flush the implementation stream.

1 files changed, 4 insertions(+), 1 deletions(-)

lib/std/http.zig+4-1
......@@ -803,7 +803,7 @@ pub const BodyWriter = struct {
803803 }
804804
805805 /// When using content-length, asserts that the amount of data sent matches
806 /// the value sent in the header, then flushes.
806 /// the value sent in the header, then flushes `http_protocol_output`.
807807 ///
808808 /// When using transfer-encoding: chunked, writes the end-of-stream message
809809 /// with empty trailers, then flushes the stream to the system. Asserts any
......@@ -827,10 +827,13 @@ pub const BodyWriter = struct {
827827 ///
828828 /// Respects the value of `isEliding` to omit all data after the headers.
829829 ///
830 /// Does not flush `http_protocol_output`, but does flush `writer`.
831 ///
830832 /// See also:
831833 /// * `end`
832834 /// * `endChunked`
833835 pub fn endUnflushed(w: *BodyWriter) Error!void {
836 try w.writer.flush();
834837 switch (w.state) {
835838 .end => unreachable,
836839 .content_length => |len| {