summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-11-04 18:59:07 +0100
committerGitHub <noreply@github.com>2022-11-04 18:59:07 +0100
commit1410e4adea5d399f9551ff04c6863862f169ee7a (patch)
treebecdab3412099f20200797a64ca22951cecf72f5 /ext
parent61fbfabe440f1cfffa7b8d17426ffdece4d430d0 (diff)
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.
Diffstat (limited to 'ext')
-rw-r--r--ext/http/lib.rs6
1 files changed, 5 insertions, 1 deletions
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.