diff --git a/src/async_impl/h3_client/mod.rs b/src/async_impl/h3_client/mod.rs index 64251321a..a4040f147 100644 --- a/src/async_impl/h3_client/mod.rs +++ b/src/async_impl/h3_client/mod.rs @@ -15,6 +15,7 @@ use std::future::{self, Future}; use std::pin::Pin; use std::task::{Context, Poll}; use std::time::Duration; +use sync_wrapper::SyncWrapper; #[derive(Clone)] pub(crate) struct H3Client { @@ -77,24 +78,24 @@ impl H3Client { Ok(s) => s, Err(e) => { return H3ResponseFuture { - inner: Box::pin(future::ready(Err(e))), + inner: SyncWrapper::new(Box::pin(future::ready(Err(e)))), } } }; H3ResponseFuture { - inner: Box::pin(self.clone().send_request(pool_key, req)), + inner: SyncWrapper::new(Box::pin(self.clone().send_request(pool_key, req))), } } } pub(crate) struct H3ResponseFuture { - inner: Pin, Error>> + Send>>, + inner: SyncWrapper, Error>> + Send>>>, } impl Future for H3ResponseFuture { type Output = Result, Error>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - self.inner.as_mut().poll(cx) + self.inner.get_mut().as_mut().poll(cx) } } diff --git a/tests/http3.rs b/tests/http3.rs index 9f097f6c3..7bd52ba65 100644 --- a/tests/http3.rs +++ b/tests/http3.rs @@ -7,6 +7,8 @@ use http::header::CONTENT_LENGTH; use std::error::Error; use support::server; +fn assert_send_sync(_: &T) {} + #[tokio::test] async fn http3_request_full() { use http_body_util::BodyExt; @@ -19,7 +21,7 @@ async fn http3_request_full() { }); let url = format!("https://{}/content-length", server.addr()); - let res = reqwest::Client::builder() + let res_fut = reqwest::Client::builder() .http3_prior_knowledge() .danger_accept_invalid_certs(true) .build() @@ -27,9 +29,10 @@ async fn http3_request_full() { .post(url) .version(http::Version::HTTP_3) .body("hello") - .send() - .await - .expect("request"); + .send(); + + assert_send_sync(&res_fut); + let res = res_fut.await.expect("request"); assert_eq!(res.version(), http::Version::HTTP_3); assert_eq!(res.status(), reqwest::StatusCode::OK);