From 1410e4adea5d399f9551ff04c6863862f169ee7a Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 4 Nov 2022 18:59:07 +0100 Subject: fix(ext/http): flush chunk when streaming resource (#16536) When streaming a resource in ext/http, with compression enabled, we didn't flush individual chunks. This became very problematic when we enabled `req.body` from `fetch` for FastStream recently. This commit now correctly flushes each resource chunk after compression. --- ext/http/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ext/http') diff --git a/ext/http/lib.rs b/ext/http/lib.rs index e71d9fae3..af117d3f9 100644 --- a/ext/http/lib.rs +++ b/ext/http/lib.rs @@ -769,7 +769,11 @@ async fn op_http_write_resource( match &mut *wr { HttpResponseWriter::Body(body) => { - if let Err(err) = body.write_all(&view).await { + let mut result = body.write_all(&view).await; + if result.is_ok() { + result = body.flush().await; + } + if let Err(err) = result { assert_eq!(err.kind(), std::io::ErrorKind::BrokenPipe); // Don't return "broken pipe", that's an implementation detail. // Pull up the failure associated with the transport connection instead. -- cgit v1.2.3