diff --git a/rama-http-backend/src/client/conn.rs b/rama-http-backend/src/client/conn.rs index 683a9332..9331e308 100644 --- a/rama-http-backend/src/client/conn.rs +++ b/rama-http-backend/src/client/conn.rs @@ -116,7 +116,7 @@ where } }); - let svc = HttpClientService(SendRequest::Http2(sender)); + let svc = HttpClientService(SendRequest::Http2(Mutex::new(sender))); Ok(EstablishedClientConnection { ctx, diff --git a/rama-http-backend/src/client/svc.rs b/rama-http-backend/src/client/svc.rs index c2fa5620..42e80d80 100644 --- a/rama-http-backend/src/client/svc.rs +++ b/rama-http-backend/src/client/svc.rs @@ -14,10 +14,10 @@ use tokio::sync::Mutex; #[derive(Debug)] // TODO: once we have hyper as `rama_core` we can -// drop the cloning / mutex / something approach as we can operate on reference layer +// drop this mutex as there is no inherint reason for `sender` to be mutable... pub(super) enum SendRequest { Http1(Mutex>), - Http2(hyper::client::conn::http2::SendRequest), + Http2(Mutex>), } #[derive(Debug)] @@ -49,7 +49,7 @@ where let resp = match &self.0 { SendRequest::Http1(sender) => sender.lock().await.send_request(req).await, - SendRequest::Http2(sender) => sender.clone().send_request(req).await, + SendRequest::Http2(sender) => sender.lock().await().send_request(req).await, }?; Ok(resp.map(rama_http_types::Body::new))