Commit 6244f5c6cb

Andrew Kelley <andrew@ziglang.org>
2025-08-08 03:03:55
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 parent af2ac24
Changed files (1)
lib
lib/std/http.zig
@@ -803,7 +803,7 @@ pub const BodyWriter = struct {
     }
 
     /// When using content-length, asserts that the amount of data sent matches
-    /// the value sent in the header, then flushes.
+    /// the value sent in the header, then flushes `http_protocol_output`.
     ///
     /// When using transfer-encoding: chunked, writes the end-of-stream message
     /// with empty trailers, then flushes the stream to the system. Asserts any
@@ -827,10 +827,13 @@ pub const BodyWriter = struct {
     ///
     /// Respects the value of `isEliding` to omit all data after the headers.
     ///
+    /// Does not flush `http_protocol_output`, but does flush `writer`.
+    ///
     /// See also:
     /// * `end`
     /// * `endChunked`
     pub fn endUnflushed(w: *BodyWriter) Error!void {
+        try w.writer.flush();
         switch (w.state) {
             .end => unreachable,
             .content_length => |len| {