From 55c5e41e1b44cabff3f72fe9750317b4b0afe9e7 Mon Sep 17 00:00:00 2001 From: Kiron Date: Mon, 20 Nov 2023 16:14:44 +0800 Subject: [PATCH] fix(client): add missing without_shutdown method --- 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..1ead6e3eca 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); + 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.