diff --git a/awc/src/connect.rs b/awc/src/connect.rs index 5b1a0d90b..a9b7a8ab2 100644 --- a/awc/src/connect.rs +++ b/awc/src/connect.rs @@ -1,6 +1,5 @@ use std::{ fmt, - future::Future, io, net, pin::Pin, task::{Context, Poll}, @@ -14,34 +13,28 @@ use actix_http::{ RequestHead, RequestHeadType, ResponseHead, }; use actix_service::Service; +use futures_core::future::LocalBoxFuture; use crate::response::ClientResponse; pub(crate) struct ConnectorWrapper(pub T); +type TunnelResponse = (ResponseHead, Framed); + pub(crate) trait Connect { fn send_request( &mut self, head: RequestHeadType, body: Body, addr: Option, - ) -> Pin>>>; + ) -> LocalBoxFuture<'static, Result>; /// Send request, returns Response and Framed fn open_tunnel( &mut self, head: RequestHead, addr: Option, - ) -> Pin< - Box< - dyn Future< - Output = Result< - (ResponseHead, Framed), - SendRequestError, - >, - >, - >, - >; + ) -> LocalBoxFuture<'static, Result>; } impl Connect for ConnectorWrapper @@ -58,7 +51,7 @@ where head: RequestHeadType, body: Body, addr: Option, - ) -> Pin>>> { + ) -> LocalBoxFuture<'static, Result> { // connect to the host let fut = self.0.call(ClientConnect { uri: head.as_ref().uri.clone(), @@ -79,16 +72,7 @@ where &mut self, head: RequestHead, addr: Option, - ) -> Pin< - Box< - dyn Future< - Output = Result< - (ResponseHead, Framed), - SendRequestError, - >, - >, - >, - > { + ) -> LocalBoxFuture<'static, Result> { // connect to the host let fut = self.0.call(ClientConnect { uri: head.uri.clone(),