Skip to content

Commit 5ad241c

Browse files
authored
Use UnsyncBoxBody everywhere in wasi-http (#12060)
This applies the changes from #11941 to the entire crate as opposed to just the WASIp3 side of things. This is required, for example, to update Wasmtime in Spin without more invasive surgery.
1 parent 6fdbe45 commit 5ad241c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

crates/wasi-http/src/body.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use anyhow::anyhow;
55
use bytes::Bytes;
66
use http_body::{Body, Frame};
77
use http_body_util::BodyExt;
8-
use http_body_util::combinators::BoxBody;
8+
use http_body_util::combinators::UnsyncBoxBody;
99
use std::future::Future;
1010
use std::mem;
1111
use std::task::{Context, Poll};
@@ -15,10 +15,10 @@ use wasmtime_wasi::p2::{InputStream, OutputStream, Pollable, StreamError};
1515
use wasmtime_wasi::runtime::{AbortOnDropJoinHandle, poll_noop};
1616

1717
/// Common type for incoming bodies.
18-
pub type HyperIncomingBody = BoxBody<Bytes, types::ErrorCode>;
18+
pub type HyperIncomingBody = UnsyncBoxBody<Bytes, types::ErrorCode>;
1919

2020
/// Common type for outgoing bodies.
21-
pub type HyperOutgoingBody = BoxBody<Bytes, types::ErrorCode>;
21+
pub type HyperOutgoingBody = UnsyncBoxBody<Bytes, types::ErrorCode>;
2222

2323
/// The concrete type behind a `was:http/types.incoming-body` resource.
2424
#[derive(Debug)]
@@ -481,7 +481,7 @@ impl HostOutgoingBody {
481481
body_receiver,
482482
finish_receiver: Some(finish_receiver),
483483
}
484-
.boxed();
484+
.boxed_unsync();
485485

486486
let output_stream = BodyWriteStream::new(context, chunk_size, body_sender, written.clone());
487487

crates/wasi-http/src/http_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ where
8686
let body = req.body.unwrap_or_else(|| {
8787
Empty::<Bytes>::new()
8888
.map_err(|_| unreachable!("Infallible error"))
89-
.boxed()
89+
.boxed_unsync()
9090
});
9191

9292
let request = builder

crates/wasi-http/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ pub trait WasiHttpView {
9292
req: hyper::Request<B>,
9393
) -> wasmtime::Result<Resource<HostIncomingRequest>>
9494
where
95-
B: Body<Data = Bytes, Error = hyper::Error> + Send + Sync + 'static,
95+
B: Body<Data = Bytes, Error = hyper::Error> + Send + 'static,
9696
Self: Sized,
9797
{
9898
let (parts, body) = req.into_parts();
99-
let body = body.map_err(crate::hyper_response_error).boxed();
99+
let body = body.map_err(crate::hyper_response_error).boxed_unsync();
100100
let body = HostIncomingBody::new(
101101
body,
102102
// TODO: this needs to be plumbed through
@@ -476,7 +476,7 @@ pub async fn default_send_request_handler(
476476
.await
477477
.map_err(|_| types::ErrorCode::ConnectionReadTimeout)?
478478
.map_err(hyper_request_error)?
479-
.map(|body| body.map_err(hyper_request_error).boxed());
479+
.map(|body| body.map_err(hyper_request_error).boxed_unsync());
480480

481481
Ok(IncomingResponse {
482482
resp,
@@ -600,7 +600,7 @@ impl TryFrom<HostOutgoingResponse> for hyper::Response<HyperOutgoingBody> {
600600
None => builder.body(
601601
Empty::<bytes::Bytes>::new()
602602
.map_err(|_| unreachable!("Infallible error"))
603-
.boxed(),
603+
.boxed_unsync(),
604604
),
605605
}
606606
}

crates/wasi-http/tests/all/p2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ async fn do_wasi_http_hash_all(override_send_request: bool) -> Result<()> {
285285
Ok(IncomingResponse {
286286
resp: resp.map(|body| {
287287
body.map_err(wasmtime_wasi_http::hyper_response_error)
288-
.boxed()
288+
.boxed_unsync()
289289
}),
290290
worker: None,
291291
between_bytes_timeout,

0 commit comments

Comments
 (0)