From 1297c9a8f379d89691522c5cc0c6071c479e95a1 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Sat, 23 Dec 2023 08:58:20 -0700 Subject: chore(ext/node): use BufView natively in http2 (#21688) Node HTTP/2 was using the default h2 `Bytes` datatype when we can be making using of `BufView` like we do in `Deno.serve`. `fetch` and `Deno.serverHttp` can't make use of `BufView` because they are using `reqwest` which is stuck on hyper 0.x at this time. --- ext/fetch/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ext/fetch') diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index 6e1ecb5e4..737bc45c1 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -14,6 +14,7 @@ use std::sync::Arc; use std::task::Context; use std::task::Poll; +use bytes::Bytes; use deno_core::anyhow::Error; use deno_core::error::type_error; use deno_core::error::AnyError; @@ -233,7 +234,7 @@ unsafe impl Send for ResourceToBodyAdapter {} unsafe impl Sync for ResourceToBodyAdapter {} impl Stream for ResourceToBodyAdapter { - type Item = Result; + type Item = Result; fn poll_next( self: Pin<&mut Self>, @@ -250,9 +251,9 @@ impl Stream for ResourceToBodyAdapter { Ok(buf) if buf.is_empty() => Poll::Ready(None), Ok(_) => { this.1 = Some(this.0.clone().read(64 * 1024)); - Poll::Ready(Some(res)) + Poll::Ready(Some(res.map(|b| b.to_vec().into()))) } - _ => Poll::Ready(Some(res)), + _ => Poll::Ready(Some(res.map(|b| b.to_vec().into()))), }, } } else { -- cgit v1.2.3