diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-12-23 08:58:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-23 08:58:20 -0700 |
commit | 1297c9a8f379d89691522c5cc0c6071c479e95a1 (patch) | |
tree | 7462b173b6b8106ea6255da67c265fcfd3a20c0d /ext/fetch/lib.rs | |
parent | 36536c784ca981ae01d258d4239b2a362017d533 (diff) |
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.
Diffstat (limited to 'ext/fetch/lib.rs')
-rw-r--r-- | ext/fetch/lib.rs | 7 |
1 files changed, 4 insertions, 3 deletions
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<BufView, Error>; + type Item = Result<Bytes, Error>; 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 { |