Skip to content

Commit 210bfaa

Browse files
authoredNov 21, 2023
feat(client): add http1::Connection without_shutdown() method (#3430)
1 parent abf696a commit 210bfaa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎src/client/conn/http1.rs

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ where
8888
pub fn poll_without_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<crate::Result<()>> {
8989
self.inner.poll_without_shutdown(cx)
9090
}
91+
92+
/// Prevent shutdown of the underlying IO object at the end of service the request,
93+
/// instead run `into_parts`. This is a convenience wrapper over `poll_without_shutdown`.
94+
pub async fn without_shutdown(self) -> crate::Result<Parts<T>> {
95+
let mut conn = Some(self);
96+
futures_util::future::poll_fn(move |cx| -> Poll<crate::Result<Parts<T>>> {
97+
ready!(conn.as_mut().unwrap().poll_without_shutdown(cx))?;
98+
Poll::Ready(Ok(conn.take().unwrap().into_parts()))
99+
})
100+
.await
101+
}
91102
}
92103

93104
/// A builder to configure an HTTP connection.

0 commit comments

Comments
 (0)
Please sign in to comment.