Skip to content

Commit 6244f5c

Browse files
committed
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 commit 6244f5c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/std/http.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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| {

0 commit comments

Comments
 (0)