Skip to content

Commit 3e7f4fe

Browse files
committed
Don't bake hyper's future into RequestClient::request
1 parent 59a6cc1 commit 3e7f4fe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/buck2_http/src/client.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use bytes::Bytes;
1515
use dupe::Dupe;
1616
use futures::StreamExt;
1717
use futures::TryStreamExt;
18+
use futures::future::BoxFuture;
1819
use futures::stream::BoxStream;
1920
use http::Method;
2021
use http::Uri;
@@ -23,7 +24,6 @@ use http::uri::Scheme;
2324
use hyper::Body;
2425
use hyper::Request;
2526
use hyper::Response;
26-
use hyper::client::ResponseFuture;
2727
use hyper::client::connect::Connect;
2828
use tokio::io::AsyncReadExt;
2929
use tokio_util::io::StreamReader;
@@ -204,15 +204,17 @@ impl HttpClient {
204204
/// ProxyConnector<HttpsConnector<..>>, etc); thus wrap the client so we can switch
205205
/// out the concrete type without exposing implementation details to callers.
206206
pub(super) trait RequestClient: Send + Sync {
207-
fn request(&self, request: Request<Bytes>) -> ResponseFuture;
207+
fn request(&self, request: Request<Bytes>) -> ResponseFuture<'_>;
208208
}
209209

210+
type ResponseFuture<'a> = BoxFuture<'a, hyper::Result<Response<Body>>>;
211+
210212
impl<C> RequestClient for hyper::Client<C>
211213
where
212214
C: Connect + Clone + Send + Sync + 'static,
213215
{
214-
fn request(&self, request: Request<Bytes>) -> ResponseFuture {
215-
self.request(request.map(Body::from))
216+
fn request(&self, request: Request<Bytes>) -> ResponseFuture<'_> {
217+
Box::pin(self.request(request.map(Body::from)))
216218
}
217219
}
218220

0 commit comments

Comments
 (0)