A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Use `UnsyncBoxBody` everywhere in wasi-http (#12060)
Alex Crichton5ad241c7a3e0
diff --git a/crates/wasi-http/src/body.rs b/crates/wasi-http/src/body.rsindex 77aa307520..0f3cb755b5 100644--- a/crates/wasi-http/src/body.rs+++ b/crates/wasi-http/src/body.rs@@ -5,7 +5,7 @@ use anyhow::anyhow;use bytes::Bytes;use http_body::{Body, Frame};use http_body_util::BodyExt;-use http_body_util::combinators::BoxBody;+use http_body_util::combinators::UnsyncBoxBody;use std::future::Future;use std::mem;use std::task::{Context, Poll};@@ -15,10 +15,10 @@ use wasmtime_wasi::p2::{InputStream, OutputStream, Pollable, StreamError};use wasmtime_wasi::runtime::{AbortOnDropJoinHandle, poll_noop};/// Common type for incoming bodies.-pub type HyperIncomingBody = BoxBody<Bytes, types::ErrorCode>;+pub type HyperIncomingBody = UnsyncBoxBody<Bytes, types::ErrorCode>;/// Common type for outgoing bodies.-pub type HyperOutgoingBody = BoxBody<Bytes, types::ErrorCode>;+pub type HyperOutgoingBody = UnsyncBoxBody<Bytes, types::ErrorCode>;/// The concrete type behind a `was:http/types.incoming-body` resource.#[derive(Debug)]@@ -481,7 +481,7 @@ impl HostOutgoingBody {body_receiver,finish_receiver: Some(finish_receiver),}- .boxed();+ .boxed_unsync();let output_stream = BodyWriteStream::new(context, chunk_size, body_sender, written.clone());diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rsindex 5f61b6e250..a50efd06a5 100644--- a/crates/wasi-http/src/http_impl.rs+++ b/crates/wasi-http/src/http_impl.rs@@ -86,7 +86,7 @@ wherelet body = req.body.unwrap_or_else(|| {Empty::<Bytes>::new().map_err(|_| unreachable!("Infallible error"))- .boxed()+ .boxed_unsync()});let request = builderdiff --git a/crates/wasi-http/src/types.rs b/crates/wasi-http/src/types.rsindex 22c3feeda2..0eb1d31a93 100644--- a/crates/wasi-http/src/types.rs+++ b/crates/wasi-http/src/types.rs@@ -92,11 +92,11 @@ pub trait WasiHttpView {req: hyper::Request<B>,) -> wasmtime::Result<Resource<HostIncomingRequest>>where- B: Body<Data = Bytes, Error = hyper::Error> + Send + Sync + 'static,+ B: Body<Data = Bytes, Error = hyper::Error> + Send + 'static,Self: Sized,{let (parts, body) = req.into_parts();- let body = body.map_err(crate::hyper_response_error).boxed();+ let body = body.map_err(crate::hyper_response_error).boxed_unsync();let body = HostIncomingBody::new(body,// TODO: this needs to be plumbed through@@ -476,7 +476,7 @@ pub async fn default_send_request_handler(.await.map_err(|_| types::ErrorCode::ConnectionReadTimeout)?.map_err(hyper_request_error)?- .map(|body| body.map_err(hyper_request_error).boxed());+ .map(|body| body.map_err(hyper_request_error).boxed_unsync());Ok(IncomingResponse {resp,@@ -600,7 +600,7 @@ impl TryFrom<HostOutgoingResponse> for hyper::Response<HyperOutgoingBody> {None => builder.body(Empty::<bytes::Bytes>::new().map_err(|_| unreachable!("Infallible error"))- .boxed(),+ .boxed_unsync(),),}}diff --git a/crates/wasi-http/tests/all/p2.rs b/crates/wasi-http/tests/all/p2.rsindex 5c5b2c962b..bdf0946cea 100644--- a/crates/wasi-http/tests/all/p2.rs+++ b/crates/wasi-http/tests/all/p2.rs@@ -285,7 +285,7 @@ async fn do_wasi_http_hash_all(override_send_request: bool) -> Result<()> {Ok(IncomingResponse {resp: resp.map(|body| {body.map_err(wasmtime_wasi_http::hyper_response_error)- .boxed()+ .boxed_unsync()}),worker: None,between_bytes_timeout,