diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-06-14 22:10:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 22:10:55 +0200 |
commit | 1246a433f8101c03491c1f1e9e0d51d79a025956 (patch) | |
tree | 10f96ad60bfef424f32f88388f31b5e1a240d2fc /runtime/ops/http.rs | |
parent | f48d66b2b01fef0f16beb35a66f1b4d5771e3b6e (diff) |
fix: poll connection after writing response chunk in Deno.serveHttp() (#10961)
This commit changes "op_http_response_write" to first send response chunk
and then poll the underlying HTTP connection.
Previously after writing a chunk of response HTTP connection wasn't polled
and thus data wasn't written to the socket until after next op interacting
with the connection.
Diffstat (limited to 'runtime/ops/http.rs')
-rw-r--r-- | runtime/ops/http.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index 11e83f6c7..3e8a4ada7 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -502,6 +502,9 @@ async fn op_http_response_write( let mut send_data_fut = body.send_data(Vec::from(&*buf).into()).boxed_local(); poll_fn(|cx| { + let r = send_data_fut.poll_unpin(cx).map_err(AnyError::from); + + // Poll connection so the data is flushed if let Poll::Ready(Err(e)) = conn_resource.poll(cx) { // close ConnResource // close RequestResource associated with connection @@ -509,7 +512,7 @@ async fn op_http_response_write( return Poll::Ready(Err(e)); } - send_data_fut.poll_unpin(cx).map_err(AnyError::from) + r }) .await?; |