From ad504977b520a9582e5516a08b2f1028ef1b5e45 Mon Sep 17 00:00:00 2001 From: kiron1 Date: Mon, 20 Nov 2023 21:34:34 +0800 Subject: [PATCH] feat(client): add `conn::http1::Connection::without_shutdown()` method (#3431) --- src/client/conn/http1.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/client/conn/http1.rs b/src/client/conn/http1.rs index e91ae507ae..37eda04067 100644 --- a/src/client/conn/http1.rs +++ b/src/client/conn/http1.rs @@ -93,6 +93,16 @@ where .expect("algready upgraded") .poll_without_shutdown(cx) } + + /// Prevent shutdown of the underlying IO object at the end of service the request, + /// instead run `into_parts`. This is a convenience wrapper over `poll_without_shutdown`. + pub fn without_shutdown(self) -> impl Future>> { + let mut conn = Some(self); + futures_util::future::poll_fn(move |cx| -> Poll>> { + ready!(conn.as_mut().unwrap().poll_without_shutdown(cx))?; + Poll::Ready(Ok(conn.take().unwrap().into_parts())) + }) + } } /// A builder to configure an HTTP connection.